1 //1302011方春阳 计科13-1 2 #include<stdio.h> 3 #include <time.h> 4 #include<stdlib.h> 5 6 #define N 45 7 main() 8 { 9 int a,b,k,i,n; 10 float c,d; 11 srand(time(NULL)); 12 do{ 13 printf(" 请输入数字类型(1.整数 2.小数) -1为退出程序: "); 14 scanf("%d",&n); 15 16 switch(n) 17 { 18 case 1: 19 { 20 for(i=0;i<N;i++) 21 { 22 a=rand()%100+1; 23 b=rand()%100+1; 24 k=rand()%4+1; 25 printf("%d",a); 26 switch(k) 27 { 28 case 1:printf("+");break; 29 case 2:printf("-");break; 30 case 3:printf("*");break; 31 case 4:printf("/");break; 32 } 33 printf("%d= ",b); 34 } 35 break; 36 } 37 break; 38 case 2: 39 { 40 for(i=0;i<N;i++) 41 { 42 c=rand()*0.001+1; 43 d=rand()*0.001+1; 44 k=rand()%4+1; 45 printf("%0.2f",c); 46 switch(k) 47 { 48 case 1:printf("+");break; 49 case 2:printf("-");break; 50 case 3:printf("*");break; 51 case 4:printf("/");break; 52 } 53 printf("%0.2f= ",d); 54 } 55 break; 56 } 57 break; 58 } 59 } 60 while(n!=-1); 61 } 62 //2016.03.16
我是计科13-1班的方春阳,通过这次学习,我将理论与实践相结合,受益匪浅。