第一次作业
#include<stdio.h> #include<stdlib.h> #include<time.h> main() { int choice; int a,b,c; srand((unsigned) time(NULL)); printf("\n\n-------------每天一练-------------"); printf("\n1.加法运算:"); printf("\n2.减法运算:"); printf("\n3.乘法运算:"); printf("\n4.除法运算:"); printf("\n5.退出练习:"); while(1) { printf("\n\n请选择所需要的练习:"); scanf("%d",&choice); switch(choice) { case 1: a=rand()%99; b=99-a; printf("\n\n%d+%d=?",a,b); break; case 2: a=rand()%99; b=99-a; printf("\n\n%d-%d=?",a,b); break; case 3: a=rand()%10; b=50-a; printf("\n\n%d*%d=?",a,b); break; case 4: a=rand()%50; b=100-a; printf("\n\n%d/%d=?",a,b); break; case 5: printf("\n\n欢迎使用每课一练!!"); exit(0); break; default: printf("输入错误,请重新输入(1-5):"); } } }