书上的代码看不懂#includemain(){ char ch;int a,b;do{printf("\n exercise for primary student");printf("\n 1.add");printf("\n 2.subtraction");printf("\n 3.multiplicative");printf("\n 4.divide");printf("\n 5.exit");printf("\n please choice(1~5)an
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 09:38:45
书上的代码看不懂#includemain(){ char ch;int a,b;do{printf("\n exercise for primary student");printf("\n 1.add");printf("\n 2.subtraction");printf("\n 3.multiplicative");printf("\n 4.divide");printf("\n 5.exit");printf("\n please choice(1~5)an
书上的代码看不懂
#includemain(){ char ch;int a,b;do{printf("\n exercise for primary student");printf("\n 1.add");printf("\n 2.subtraction");printf("\n 3.multiplicative");printf("\n 4.divide");printf("\n 5.exit");printf("\n please choice(1~5)and input numbers");scanf("%d%d",&a,&b);ch=getchar();getchar();switch(ch){case '1':printf("\n add sum is %d",a+b); break;case '2':printf("\n subtraction",a-b); break;case '3':printf("\n multiplicative",a*b); break;case '4':printf("\n divide",a/b); break;case '5':printf("\n end."); break;default:printf("\n error.choice again."); break;}}while(ch!='5');}
其中
scanf("%d%d",&a,&b);ch=getchar();getchar();
还有程序好像不成功
书上的代码看不懂#includemain(){ char ch;int a,b;do{printf("\n exercise for primary student");printf("\n 1.add");printf("\n 2.subtraction");printf("\n 3.multiplicative");printf("\n 4.divide");printf("\n 5.exit");printf("\n please choice(1~5)an
scanf("%d%d",&a,&b);
的意思是从键盘读入两个整数,第一个给a,第二个给b
ch=getchar();
的意思是从键盘读入一个字符给ch
getchar();
的意思是从键盘读入任意一个字符(可以理解为等待用户在键盘敲一个键,然后从能继续运行)