Task1
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 #define N 5 5 #define N1 374 6 #define N2 465 7 int main() 8 { 9 int number; 10 int i; 11 srand( time(0) ); // 以当前系统时间作为随机种子 12 for(i = 0; i < N; ++i) { 13 number = rand()%(N2 - N1 + 1) + N1; 14 printf("202383290376%04d\n", number); 15 } 16 return 0; 17 }
Rs1
q1:生成N1到N2之间到一个数
q2:随机指定202383290376374到202383290376465之间到五个数字 Task21 #include <stdio.h> 2 int main(){ 3 char c; 4 while(scanf("%c",&c)!=EOF){ 5 getchar(); 6 switch(c){ 7 case 'r':printf("stop!\n");break; 8 case 'g':printf("go go go\n");break; 9 case 'y':printf("wait a minute\n");break; 10 default:printf("something must be wrong...\n"); 11 } 12 } 13 return 0; 14 }
Rs2
Task3
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 int main(){ 5 printf("猜猜2023年11月哪一天是你到luck day\n开始喽,你有3次机会,"); 6 printf("猜吧(1~30):"); 7 int i,n,t; 8 srand(time(0)); 9 n=rand()%31; 10 for(i=1;i<=3;i++){ 11 scanf("%d",&t); 12 if(t==n){ 13 printf("哇,猜中啦:)"); 14 break; 15 } 16 if(t>n&&i<3){ 17 printf("你猜的日期晚啦,你的luck day已然过了。\n再猜(1~30):"); 18 } 19 if(t<n&&i<3){ 20 printf("你猜的日期早啦,你的luck day还没到。\n再猜(1~30):"); 21 } 22 if(t!=n&&i==3){ 23 printf("次数用完啦,偷偷告诉你,11月,你的luck day是%d",n); 24 } 25 } 26 return 0; 27 }
Rs3
Task4
1 #include<stdio.h> 2 int main(){ 3 int a,n,i; 4 double sign=1.0; 5 while(scanf("%d%d",&n,&a)!=EOF){ 6 int f=a; 7 double s=0; 8 for(i=1;i<=n;i++){ 9 s+=sign*i/f; 10 f=10*f+a; 11 } 12 printf("n=%d,a=%d,s=%.6lf\n",n,a,s); 13 } 14 return 0; 15 }
Rs4
Task5
1 #include<stdio.h> 2 int main(){ 3 int i,j; 4 for(i=1;i<=9;i++){ 5 for(j=1;j<=i;j++){ 6 printf("%d * %d = %d ",j,i,j*i); 7 } 8 printf("\n"); 9 } 10 return 0; 11 }
Rs5
Task6
1 #include<stdio.h> 2 #include<string.h> 3 int main(){ 4 int i,j,k,n; 5 char c[10]; 6 scanf("%d",&n); 7 for(k=n;k>=1;k--){ 8 for(i=1;i<=3;i++){ 9 if(i==1){ 10 strcpy(c," o "); 11 if(k<=n) 12 printf("\n"); 13 } 14 if(i==2){ 15 printf("\n"); 16 strcpy(c,"<H>"); 17 } 18 if(i==3){ 19 printf("\n"); 20 strcpy(c,"I I"); 21 } 22 for(j=1;j<=2*n-1;j++){ 23 if(k>n-j&&k>j-n) 24 printf("%s ",c); 25 else 26 printf(" "); 27 } 28 } 29 } 30 return 0; 31 }
Rs6
标签:10,include,int,实验,printf,N1,main From: https://www.cnblogs.com/KXJSLL/p/17773598.html