You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pj8a4cfvw b4b3dbbd3c
Update README.md
1 year ago
00.c ADD file via upload 1 year ago
README.md Update README.md 1 year ago

README.md

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

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;

}