#include<stdio.h> #include<stdlib.h> #include<time.h> #define N 5 int main() { int number; int i; srand(time(0)); for(i=0;i<N;i++){ number=rand()%500+1; printf("20228329%d04\n",number); } return 0; }
#include<stdio.h> #include<stdlib.h> #include<time.h> #define N 1 int main() { int number,n,a; srand(time(0)); number=rand()%30+1; printf("猜猜2022年11月哪一天会是你的lucky day\n"); printf("开始喽,你有三次机会,猜吧(1~30): "); for(n=1;n<=3;){ scanf("%d",&a); if(a==number) {printf("哇,猜中了:~\n");break; } else if(a<number) {printf("你猜的日期早了,你的lucky day还没到呢\n"); } else {printf("你猜的日期晚了,你的lucky day已经过啦\n"); } n++; if(n>3)break; printf("再猜(1~30): "); } if(n>3) {printf("次数用完,偷偷告诉你:11月,你的lucky day是%d号\n",number); } return 0; }
#include<stdio.h> #include<stdlib.h> int main() { char light; while(scanf("%c",&light)!=EOF){ switch(light) { case 'y':printf("wait a minute\n");getchar();break; case 'g':printf("go go go\n");getchar();break; case 'r':printf("stop\n");getchar();break; default:printf("something must be wrong\n");getchar();break; } } return 0; }
#include <stdio.h> #include<math.h> int main() { int n, a, i; double s; while (1) { scanf_s("%d%d", &n, &a); for (i = 1, s = 0; i <= n; ++i); { s +=1.0 * i / pow(a, i); } printf("n=%d,a=%d,s=%lf", n, a, s); printf("\n"); } return 0; }
#include<stdio.h> int main() { int i, j; for (i = 1; i < 10; i++) { for (j = 1; j <= i; j++) { printf("%d*%d=%-3d ", j, i, i * j); } printf("\n"); } return 0; }
#include<stdio.h> int main() { int i, j, n; scanf_s("%d", &n); for (i = 1; i <= n; ++i) { for (j = 1; j <= 2 * n - 1; ++j) { if (i > j||j>2*n-i) { printf("\t"); } else printf(" 0\t"); } printf("\n"); for (j = 1; j <= 2 * n - 1; ++j) { if (i > j || j > 2 * n - i) { printf("\t"); } else printf("<H>\t"); } printf("\n"); for (j = 1; j <= 2 * n - 1; ++j) { if (i > j || j > 2 * n - i) { printf("\t"); } else printf("I I\t"); } printf("\n"); printf("\n"); } return 0; }
标签:include,int,number,break,实验,printf,main From: https://www.cnblogs.com/Violet-/p/16825855.html