Skip to content

Instantly share code, notes, and snippets.

@daleth90
Created Nov 3, 2018
Embed
What would you like to do?
class Program {
static void Main() {
Random random = new Random();
int[] a = new int[ 10 ];
// 依序為每個元素產生 1~100 的隨機整數
int i = 0;
while ( i < a.Length ) {
a[ i ] = random.Next( 100 ) + 1;
i++;
}
// 依序印出每個元素的值
i = 0; // 將 i 重複利用
while ( i < a.Length ) {
Console.Write( a[ i ] );
if ( i != a.Length - 1 ) {
Console.Write( " " );
}
else {
Console.WriteLine();
}
i++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment