代码:
#include<stdio.h> #include<stdlib.h> #include <time.h> #define N 30 main() { int a,b,k,i,n; float c,d; srand(time(NULL)); do{ printf("
请输入数字类型(1.整数 2.小数) -1为退出程序: "); scanf("%d",&n);
switch(n) { case 1: {
for(i=0;i<N;i++) { a=rand()%100+1; b=rand()%100+1; k=rand()%4+1; printf("%d",a); switch(k) { case 1:printf("+");break; case 2:printf("-");break; case 3:printf("*");break; case 4:printf("/");break; } printf("%d= ",b); } break; } break; case 2: { for(i=0;i<N;i++) { c=rand()*0.001+1; d=rand()*0.001+1; k=rand()%4+1; printf("%0.2f",c); switch(k) { case 1:printf("+");break; case 2:printf("-");break; case 3:printf("*");break; case 4:printf("/");break; } printf("%0.2f= ",d); } break; } break; } }while(n!=-1); }
switch(n) { case 1: {
for(i=0;i<N;i++) { a=rand()%100+1; b=rand()%100+1; k=rand()%4+1; printf("%d",a); switch(k) { case 1:printf("+");break; case 2:printf("-");break; case 3:printf("*");break; case 4:printf("/");break; } printf("%d= ",b); } break; } break; case 2: { for(i=0;i<N;i++) { c=rand()*0.001+1; d=rand()*0.001+1; k=rand()%4+1; printf("%0.2f",c); switch(k) { case 1:printf("+");break; case 2:printf("-");break; case 3:printf("*");break; case 4:printf("/");break; } printf("%0.2f= ",d); } break; } break; } }while(n!=-1); }
语言:C语言
来源:百度;
https://github.com/yangyueyong199612/Hello-World/blob/master/%E5%9B%9B%E5%88%99%E8%BF%90%E7%AE%97