实验1 源代码
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 12 srand(time(0)); 13 14 for(i = 0; i < N;++i) 15 { 16 number = rand()%(N2 - N1 + 1) + N1; 17 printf("202383290376%04d\n",number); 18 } 19 20 return 0; 21 }
实验一 截屏
实验二 源代码
1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() 4 { 5 char colour; 6 7 while(scanf("%c",&colour) != EOF) 8 { 9 switch (colour) 10 { 11 case 'r': printf("stop!");break; 12 case 'g': printf("go go go");break; 13 case 'y': printf("wait a minute");break; 14 default : printf("something must be wrong");break; 15 } 16 } 17 18 system("pause"); 19 return 0; 20 }
实验二 截屏
实验三 源代码
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 int main() 5 { 6 int number, count, a; 7 srand(time(0)); 8 number = rand() % 30 + 1; 9 count = 3; 10 a = 0; 11 printf("猜\n"); 12 13 do 14 { 15 scanf("%d",&a); 16 count --; 17 if( a > number ) 18 printf("晚\n"); 19 else if( a < number ) 20 printf("早\n"); 21 }while (a != number && count > 0 ); 22 23 if( a == number ) 24 printf("对\n"); 25 else if(count == 0) 26 printf("是%d号",number); 27 28 system("pause"); 29 return 0; 30 }
实验三 截屏
实验四 源代码
1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() 4 { 5 int n, a, i, d; 6 double s; 7 d = 1; 8 s = 0; 9 10 while (scanf("%d %d",&n,&a) != EOF) 11 { 12 for (i = 1;i <= n;i++) 13 { 14 d *= a; 15 s += i*1.0/d; 16 } 17 printf("n = %d, a = %d, s = %.7f\n",n,a,s); 18 d = 1, s = 0, i = 1; 19 } 20 21 system("pause"); 22 return 0; 23 }
实验四 截屏
实验五 源代码
1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() 4 { 5 int line, first; 6 line = 1; 7 first = 1; 8 9 for (line = 1;line <= 9;line++) 10 { 11 for (first = 1;first <= line;first++) 12 { 13 i = first*line; 14 printf("%dx%d = %d ",first,line,i); 15 } 16 printf("\n"); 17 } 18 19 system("pause"); 20 return 0; 21 }
实验五 截屏
实验六 源代码
1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() 4 { 5 int n, i, m; 6 i = 0; 7 m = 0; 8 9 scanf("%d",&n); 10 11 while (n > 0) 12 { 13 for (i = 0;i < m;i++) 14 { 15 printf(" "); 16 } 17 18 for (i = 0;i <= 2*(n-1);i++) 19 { 20 printf(" o "); 21 } 22 23 printf("\n"); 24 25 for (i = 0;i < m;i++) 26 { 27 printf(" "); 28 } 29 30 for (i = 0;i <= 2*(n-1);i++) 31 { 32 printf("<H> "); 33 } 34 35 printf("\n"); 36 37 for (i = 0;i < m;i++) 38 { 39 printf(" "); 40 } 41 42 for (i = 0;i <= 2*(n-1);i++) 43 { 44 printf("I I "); 45 } 46 printf("\n"); 47 48 n--; 49 m++; 50 } 51 52 system("pause"); 53 return 0; 54 }
实验六 截屏
标签:include,int,number,实验,printf,源代码 From: https://www.cnblogs.com/7perch/p/17769673.html