/*
*Copyright (c) 2014, 烟台大学计算机学院
*All rights reserved.
*文*完成日期:2014年 11 月 2日
*版件名称:test.cpp
*作者:chendongliang
*完成日期:2014年 11 月 2日
*版本号:v1.0
*
*问题描述:
*输入描述:
*程序输出:
*/
#include <iostream>
# {
int a = 100;
int b = 20;
int c;
char oper;
cout << "请输入:";
cin>>a>>oper>>b;
switch(oper)
{
case '+':
c = a + b;
break;
case '-':
c = a - b;
break;
case '*':
c = a * b;
break;
default :
if( b==0)
c = a;
else
c = a / b;
break;
}
cout<<"c="<<c<<endl<<"N键继退出其他键继续"<<endl;
cin >>ch;
}
while(ch!='N' && ch!='n');
return 0;
}include <cstdio>
using namespace std;
int main()
{
char ch;
do
{
int a = 100;
int b = 20;
int c;
char oper;
cout << "请输入:";
cin>>a>>oper>>b;
switch(oper)
{
case '+':
c = a + b;
break;
case '-':
c = a - b;
break;
case '*':
c = a * b;
break;
default :
if( b==0)
c = a;
else
c = a / b;
break;
}
cout<<"c="<<c<<endl<<"N键继退出其他键继续"<<endl;
cin >>ch;
}
while(ch!='N' && ch!='n');
return 0;
}
运行结果: