1.å
³äºcè¯è¨ä¸çrand()
å ³äºcè¯è¨ä¸çrand()
å 为éæºæ°ç§åä¸å
ç¨srand设置ä¸ä¸ªä¸åçéæºæ°ç§åå³å¯
ä¾ç¨
/* rand example: guess the number */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
int iSecret,源码全能一休源码 iGuess;
/* initialize random seed: */
srand ( time(NULL) );
/* generate secret number: */
iSecret = rand() % + 1;
do {
printf ("Guess the number (1 to ): ");
scanf ("%d",&iGuess);
if (iSecret<iGuess) puts ("The secret number is lower");
else if (iSecret>iGuess) puts ("The secret number is higher");
} while (iSecret!=iGuess);
puts ("Congratulations!");
return 0;
}
2024-12-22 20:44
2024-12-22 20:43
2024-12-22 20:40
2024-12-22 19:28
2024-12-22 19:21
2024-12-22 18:52