task1.c源代码
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<time.h> 4 5 #define N 5 6 #define N1 374 7 #define N2 465 8 9 int main() 10 { 11 int number; 12 int i; 13 14 srand(time(0)); 15 16 for (i = 0; i < N; i++) { 17 number = rand() % (N2 - N1 + 1) + N1;//随机数生成赋予number的值 18 printf("202383290376%04d\n", number); 19 } 20 }
作用:抽五个学号
task2.c源代码
1 #define _CRT_SECURE_NO_WARNINGS 2 #include<stdio.h> 3 int main() 4 { 5 char a; 6 while (scanf("%c", &a) != EOF) 7 { 8 getchar(); 9 switch (a) 10 { 11 default: 12 printf("something must be wrong...\n"); 13 break; 14 case 'r': 15 printf("stop!\n"); 16 break; 17 case 'g': 18 printf("go go go\n"); 19 break; 20 case 'y': 21 printf("wait a minute\n"); 22 break; 23 24 } 25 26 } 27 }
task3.c源代码
1 #define _CRT_SECURE_NO_WARNINGS 2 #include<stdio.h> 3 #include<stdlib.h> 4 #include<time.h> 5 int main() 6 { 7 srand(time(0)); 8 int x; 9 int a = rand() % (30) + 1; 10 printf("猜猜2023年11月哪一天会是你的lucky day\n"); 11 printf("开始喽,你有三次机会,猜吧(1~30):"); 12 for (int i = 1; i <= 3; ++i){ 13 scanf("%d", &x); 14 15 if (x < a) 16 printf("你猜的日期早了,你的lucky day还没到呢\n再猜(1~30):"); 17 else if (x > a) 18 printf("你猜的日期晚了,你的lucky day已经过啦\n再猜(1~30):"); 19 else 20 printf("哇,猜中了"); 21 } 22 if (x != a) 23 printf("次数用完啦,偷偷告诉你:11月,你的lucky day是%d号", a); 24 }
task4.c源代码
1 #define _CRT_SECURE_NO_WARNINGS 2 #include<stdio.h> 3 #include<math.h> 4 int main() 5 { 6 int n, a; 7 while (scanf("%d%d", &n, &a) != EOF) 8 { 9 double s = 0; 10 double down = 0; 11 for (int i = 1; i <= n; ++i) { 12 down += pow(10, i - 1) * a; 13 s += i / down; 14 } 15 printf("n=%d,a=%d,s=%f", n, a, s); 16 } 17 }
task5.c源代码
1 #include<stdio.h> 2 int main() 3 { 4 int c=1, l=1; 5 for (l = 1; l <= 9; ++l) { 6 for (c = 1; c <= l; ++c) 7 printf("%d*%d=%d ", c, l, c*l); 8 printf("\n"); 9 } 10 11 }
task6.c源代码
标签:11,源代码,int,实验,printf,include,define From: https://www.cnblogs.com/ctl050312/p/17767831.html