task1
#include<stdio.h> #include<stdlib.h> #include<time.h> #define N 5 #define N1 374 #define N2 465 int main() { int number; int i; srand( time(0) ); for (i = 0;i < N;++i) { number = rand() % (N2 - N1 + 1) + N1; printf("202383290376%04d\n", number); } return 0; }
task2(有问题)
#include<stdio.h> int main(void) { char n; n = getchar(); while (scanf("%c,&n") != EOF) { if (n == 'r') { printf("stop!\n"); } else if (n == 'g') { printf("go go go\n"); } else if (n == 'y') { printf("wait a minuate\n"); } else { printf("something must be wrong\n"); } } return 0; }
task3
#include<stdio.h> #include<stdlib.h> #include<time.h> #define N 1 #define N1 1 #define N2 30 int main() { int number; int t, i, n; srand(time(0)); for (i = 0;i < N;++i) { number = rand() % (N2 - N1 + 1) + N1; } printf("先偷偷把答案告诉你:%d\n", number); printf("猜猜2023年11月那天会是你的lucky day\n"); printf("那么现在开始喽,你有三次机会,猜吧:"); for (t = 1;t <= 3;t++) { scanf("%d", &n); if (n < number) { printf("你猜的日期早啦,还没到呢\n"); } else if (n > number) { printf("你猜的日期晚啦,已经过了\n"); } else { printf("恭喜你猜对啦\n");break; return n; } } printf("次数用完辣,偷偷告诉你,你的lucky day是:%d",number); return 0; }
task4
#include<stdio.h> #include<math.h> int main() { int n, a; while (scanf("%d%d", &n, &a) != EOF) { double s = 0; double t = 0; for (int i = 1; i <= n; ++i) { t = t + pow(10, i - 1) * a; s = s + i / t; } printf("n=%d,a=%d,s=%f", n, a, s); } }
task5
#include <stdio.h> int main(){ int i,j; for(i=1;i<=9;i++){ for(j=1;j<=i;j++) printf("%d*%d=%2d ",i,j,i*j); printf("\n"); } return 0; }
task6
标签:int,number,实验,printf,N1,include,define From: https://www.cnblogs.com/Bulletproof-Picasso/p/17768280.html