OIMM

#include <stdio.h>

#include <time.h>

#include <stdlib.h>

 

 

          int main(int argc, const char * argv[]) {

    // insert code here...

     

    printf("Hello, World!\n");

    int a,b,i;

    {

        srand((unsigned int)time(0));

        b = rand()%100 + 1;

       // printf("%d\n", b);//隐藏随机产生的数。

    }

    //产生一个随机数

    while(1){

        

        printf("insert the number you thinking , please\n");

        scanf("%d",&a);//scanf里面不要有任何杂质,此处若有空格什么的会导致输入第一个数据运行不了,从第二个数据开始运行。

        

        i=i+1;

        if (a>b)

        {

            printf("太大了,小一点会更好。\n");

        }

        else if (a<b){

            printf("太小了,你应想的更大一点\n");

            

        }

        else{

            printf("恭喜你。答对了!!!\n你一共猜了%d次就猜对了!!!\n你真聪明",i);

            

            break;//没有break会一直运行下去

        }

    }

    

    

    

//        int  a,b,i;

//    

//        srand((unsigned int)time(0));

//        srand((unsigned int)time(0));

//    

//        b = rand()%100 + 1;

//        printf("%d\n", b);

//        for (i=0; i<100; i++) {

//            printf("请输入一个数字\n");

//            scanf("%d",&a);

//            if (a>b) {

//                printf("

分类:

技术点:

相关文章:

  • 2021-10-01
  • 2021-06-21
  • 2021-05-17
  • 2021-06-11
  • 2021-10-01
  • 2021-09-01
  • 2021-04-06
猜你喜欢
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
  • 2021-08-14
  • 2021-05-24
  • 2021-08-14
  • 2021-10-01
相关资源
相似解决方案