效果如下:
程序如下: #include<iostream> using namespace std; int main(){ int a , b , c; char d; cin >> a >> d >> b; if ( d == '+' ){ c = a + b; cout << "=" << c << endl; } else if( d == '-' ){ c = a - b; cout << "=" << c << endl; } else if( d == '/' ){ c = a / b; cout << "=" << c << endl; } else if( d == '*' ){ c = a * b; cout << "=" << c << endl; } else { cout << "錯誤!" << endl; } } |
|
來自: 姓C的某人 > 《信息技術(shù)》