Lv.1
我是一名小学生,喜欢Scratch编程和C++,喜欢和别人交流和分享代码
在 有谁会DEV-C++吗 中回复
#include <iostream>
#include <string>
using namespace std;
int main()
{
int a,b,o,t;
string f;
cout<<"输入第一个数,再输入运算符号,接着第二个数,然后enter\n";
while(1){ //重复判断
cin>>a;
cin>>f;
cin>>b;
if(f=="+"){ //加法运算
o=a+b;
cout<<a<<"+"<<b<<"="<<o;
}
if(f=="-"){ //减法运算
o=a-b;
cout<<a<<"-"<<b<<"="<<o;
}
if(f=="*"){ //乘法运算
o=a*b;
cout<<a<<"*"<<b<<"="<<o;
}
if(f=="/"){ //除法运算
o=a/b;
cout<<a<<"/"<<b<<"="<<o;
}
}
return 0;
}2024-07-24T14:42:34 点赞:0