This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program { | |
static void Main() { | |
Random random = new Random(); | |
int[] a = new int[ 10 ]; | |
// 依序為每個元素產生 1~100 的隨機整數 | |
int i = 0; | |
do { | |
a[ i ] = random.Next( 100 ) + 1; | |
i++; | |
} | |
while ( i < a.Length ); | |
// 依序印出每個元素的值 | |
i = 0; // 將 i 重複利用 | |
do { | |
Console.Write( a[ i ] ); | |
if ( i != a.Length - 1 ) { | |
Console.Write( " " ); | |
} | |
else { | |
Console.WriteLine(); | |
} | |
i++; | |
} | |
while ( i < a.Length ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment