#include<stdlib.h>
#include <windows.h>
#include<time.h>
#include<math.h>
#define N 99
void sign(char n)
{
int a,b,c
srand( (unsigned)time( NULL ) )
a=1+(int)(10*rand()/(RAND_MAX+1.0)) //随机数产生
b=1+(int)(10*rand()/(RAND_MAX+1.0))
printf("%d%c%d=",a,n,b)
scanf("%d",&c)
if(n=='+')
{
if(c==a+b) printf("答对了!\n")
else printf("答案是%d\n",a+b)
}
if(n=='-')
{
if(c==a-b) printf("答对了!\n")
else printf("答案是%d\n",a-b)
}
if(n=='*')
{
if(c==a*b) printf("答对了!\n")
else printf("答案是%d\n",a*b)
}
if(n=='/')
{
if(c==a/b) printf("答对了!\n")
else {printf("答案是%d\n",a/b)}
}
}
void menu()
{
printf("1.加法运算\n")
printf("2.减法运算\n")
printf("3.乘法运算\n")
printf("4.除法运算\n")
printf("0.退出程序\n")
}
void main()
{
int num,i
for(i=0i++)
{
while(1){
menu()
printf("\n请选择功能:")
scanf("%d",&num)
switch(num)
{
case 4:sign('/')break
case 3:sign('*')break
case 2:sign('-')break
case 1:sign('+')break
case 0:return
}
printf("按任意键返回菜单\n")
getch()
system("cls") //清屏
}
}
}
#includeint main(){double s int a[10000] int i,n,d while(~scanf("%d",&n)){d=0 s=0 for(i=0i=60) d++ printf("average = %.1lf\ncount = %d\n",s,d) }return 0}欢迎分享,转载请注明来源:内存溢出
评论列表(0条)