[C++] hdoj1170简单题 →→→→→进入此内容的聊天室

来自 , 2019-10-09, 写在 C++, 查看 120 次.
URL http://www.code666.cn/view/11f524c3
  1. #include<iostream>
  2. #include <iomanip>
  3. #include<string>
  4. using namespace std;
  5.  
  6. int main(){
  7.         int m;
  8.         cin>>m;
  9.         char ch;
  10.         int a, b;
  11.         for(int i = 0; i < m; i++){
  12.                 cin>>ch>>a>>b;
  13.                 if(ch == '+'){
  14.                         cout<<a + b<<endl;
  15.                 }else if(ch == '-'){
  16.                         cout<<a - b<<endl;
  17.                 }else if(ch == '*'){
  18.                         cout<<a * b<<endl;
  19.                 }else if(ch == '/'){
  20.                         if((a + 0.0) / b - (a / b) > 0){
  21.                                 cout<<fixed<<setprecision(2)<<(a + 0.0) / b<<endl;
  22.                         }else{
  23.                                 cout<<a / b<<endl;
  24.                         }
  25.                 }
  26.         }
  27. }

回复 "hdoj1170简单题"

这儿你可以回复上面这条便签

captcha