test1
#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; }
test2
1.随机生成一个数赋值给number
2.以当前系统时间作为随机种子,随机生成一个数
#include<stdio.h> int main() { char light; while ((light=getchar()) != EOF) { switch (light) { case 'r':printf("stop\n");break; case 'g':printf("go go go\n");break; case 'y':printf("wait a muinte\n");break; default :printf("something wrong");break; }
getchar(); } return 0;
}
test 3
#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { int a, b = 1, c, d = 0; srand(time(0)); a = rand() % 30+1; for (b = 1;b <= 3;b++) { scanf_s("%d", &c); if (c < a) { printf("早了\n"); d += 1; } else if (c > a) { printf("晚了\n"); d += 1; } else if (c == a) { printf("中了\n");break; } } if (d = 3) { printf("次数用完了\n"); } return 0; }
test 4
#include<stdio.h> int main() { int a, n; double every,s; int down,time; while (scanf_s("%d%d", &n,&a) != EOF) { for (time = 1,down=0,s=0;time <= n;time++) { down = down*(time-1)*10 + a; every = (time*1.0) / (down*1.0); s = every + s; } printf("%f\n", s); } return 0; }
21:22:09
test 5
#include<stdio.h> #include<math.h> int main() { int i, j; int a=1; for (i = 1, j = 1,a=1;j < 10;j++,a++) { for (i = 1;i <=a;i += 1) { printf("%d*%d=%d ", i, j, i * j); } printf("\n"); } return 0; }
#include<stdio.h> int main() { int n; int i, j,m; scanf_s("%d", &n); for (j = 1;j <= n;j++) { for (m = 1;m <= j;m++) { printf("\t"); } for (i = 1;i <= (2 * n -(j*2-1));i++) { printf(" o\t"); } printf("\n"); for (m = 1;m <= j;m++) { printf("\t"); } for (i = 1;i <= (2 * n - (j * 2 - 1));i++) { printf("<H>\t"); } printf("\n"); for (m = 1;m <= j;m++) { printf("\t"); } for (i = 1;i <= (2 * n - (j * 2 - 1));i++) { printf("I I\t"); } printf("\n"); } return 0; }
标签:include,int,time,break,实验,printf,main From: https://www.cnblogs.com/lycxt/p/17769671.html