#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;//计算num的值 printf("202383290376%04d\n", number);//生成3个前面一部分固定的随机数 } return 0; }
#include <stdio.h> int main() { char col; while(scanf("%s",&col) != EOF) { switch(col) { case 'r': printf("Stop!\n"); break; case 'g': printf("Go go go!\n"); break; case 'y': printf("Wait a minute.\n"); break; default: printf("Something must be wrong......"); break; } return 0;
}
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int tim = 0; srand(time(0)); while(tim < 1 || tim > 30) {tim = rand();} int gus,i = 1; printf("猜猜2023年哪天是你的lucky day\n开始了,你有三次机会,猜吧(1~30):"); scanf("%d",&gus); while(i <= 3) { if(gus<tim) { printf("你猜的日期早了,你的licky day 还没到呢。\n再猜(1~30):"); scanf("%d",&gus); i++; } else if(gus>tim) { printf("你猜的日期晚了,你的lucky day以及过了\n再踩(1~30):"); scanf("%d",&gus); i++; } else { printf("哇猜中了=)\n"); break; } } if(i == 4) {printf("次数用完了,偷偷告诉你:11月,你的lucky day 是%d号\n",tim);} return 0;
}
#include <stdio.h> #include <stdlib.h> int Down(int n,int a) { int y = 0; while(n>0) { y = a + y*10; n--; } return y; } int main() { int n,a; while(scanf("%d %d",&n,&a) != EOF) { double i = 1, s = 0; while(i<=n) { s = s + i/Down(i,a); i++; } printf("n = %d, a = %d, s = %.6lf",n,a,s); } return 0;
}
标签:int,break,tim,while,实验,printf,include From: https://www.cnblogs.com/5464665465L/p/17767942.html