diff --git a/README.md b/README.md index 29e3065..da7ffb9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,64 @@ -# 123 +#define _CRT_SECURE_NO_WARNINGS +#include +#include + +void test01() +{ + int num = 0; + while (num < 10) + { + printf("num=%d\n", num); + num++; + } + + +} + +//猜数字 +void test02() +{ + //设置随机数的种子 + srand((unsigned int)time(NULL));//固定代码,必须记 + //int i = 0; + //while (i < 10) + //{ + // int num=rand() % 100 + 1;//rand()会生成随机数rand对100取余会生成0-99的随机数,再加1就成0-100 + // printf("%d\n",num); + // i++; + //} + int num = rand() % 1000 + 1; + int val = 0; + + printf("请您输入一个1000以内的正整数\n"); + while (1) //()中的1为真,所以会一直循坏 + { + + scanf("%d", &val); + + if (val > num) + { + printf("输入大了\n"); + } + else if (val < num) + { + printf("输入小了\n"); + + } + else + { + printf("恭喜您,猜对了!\n"); + break; + } + + } +} + +int main() +{ + test02(); + + system("pause"); + + return 0; +}