生成随机数

#include <stdio.h> 
#include <stdlib.h> 

int main()
{
   int iRandomNum = 0;
   int iResponse = 0;

   iRandomNum = (rand() % 10) + 1;
   printf("/nGuess a number between 1 and 10: ");
   scanf("%d", &iResponse);
   if (iResponse == iRandomNum)
      printf("/nYou guessed right/n");
   else {
      printf("/nSorry, you guessed wrong/n");
      printf("The correct guess was %d/n", iRandomNum);
   }
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266765.html

(0)
上一篇 2022年6月7日
下一篇 2022年6月7日

相关推荐

发表回复

登录后才能评论