Initial commit: C language learning code

This commit is contained in:
2025-07-20 16:30:56 +08:00
commit 06e24173a6
139 changed files with 9303 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(0));
int number = rand()%100+1;
int count = 0;
int a = 0;
printf("我已经想好了一个1到100之间的数。");
do
{
printf("请猜这个1到100之间的数:");
scanf("%d", &a);
count = count+1;
if(a>number)
{
printf("你猜的数大了。");
}
else if(a<number)
{
printf("你猜的数小了。");
}
}
while(a != number);
printf("太好了,你用了%d次就猜对了。\n", count);
}