Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int a=0,c[101];
- string b[101];
- while(getline(cin,b[a]))
- a++;
- for (int i =0; i<=a;i++)
- {
- if(b[i].find("+")!=string::npos)
- {
- b[i].erase(0,2);
- int ch_place = b[i]. find(" ") ;
- string leftside_str = "" ;
- string rigthside_str = "";
- int leftside ;
- int rigthside ;
- for ( int j = 0 ; j < ch_place ; j++ )
- leftside_str +=b [i ][j] ;
- for ( int j= ++ ch_place ; j <b[i].length() ; j++ )
- rigthside_str + = b[i] [j] ;
- leftside = atoi(leftside_str. c_str ()) ;
- rigthside = atoi(rigthside_str. c_str ()) ;
- c[i] = leftside + rigthside;
- }
- if(b[i].find("-") !=string::npos)
- {
- b[i].erase(0,2);
- int ch_place = b[i]. find(" ") ;
- string leftside_str = "" ;
- string rigthside_str = "";
- int leftside ;
- int rigthside ;
- for ( int j = 0 ; j < ch_place ; j++ )
- leftside_str +=b [i ][j] ;
- for ( int j= ++ ch_place ; j <b[i].length() ; j++ )
- rigthside_str + = b[i] [j] ;
- leftside = atoi(leftside_str. c_str ()) ;
- rigthside = atoi(rigthside_str. c_str ()) ;
- c[i] = leftside - rigthside;
- }
- if(b[i].find("*") !=string::npos)
- {
- b[i].erase(0,2);
- int ch_place = b[i]. find(" ") ;
- string leftside_str = "" ;
- string rigthside_str = "";
- int leftside ;
- int rigthside ;
- for ( int j = 0 ; j < ch_place ; j++ )
- leftside_str +=b [i ][j] ;
- for ( int j= ++ ch_place ; j <b[i].length() ; j++ )
- rigthside_str + = b[i] [j] ;
- leftside = atoi(leftside_str. c_str ()) ;
- rigthside = atoi(rigthside_str. c_str ()) ;
- c[i] = leftside * rigthside;
- }
- if(b[i].find("/") !=string::npos)
- {
- b[i].erase(0,2);
- int ch_place = b[i]. find(" ") ;
- string leftside_str = "" ;
- string rigthside_str = "";
- int leftside ;
- int rigthside ;
- for ( int j = 0 ; j < ch_place ; j++ )
- leftside_str +=b [i ][j] ;
- for ( int j= ++ ch_place ; j <b[i].length() ; j++ )
- rigthside_str + = b[i] [j] ;
- leftside = atoi(leftside_str. c_str ()) ;
- rigthside = atoi(rigthside_str. c_str ()) ;
- c[i] = leftside / rigthside;
- }
- if(b[i].find("%") !=string::npos)
- {
- b[i].erase(0,2);
- int ch_place = b[i]. find(" ") ;
- string leftside_str = "" ;
- string rigthside_str = "";
- int leftside ;
- int rigthside ;
- for ( int j = 0 ; j < ch_place ; j++ )
- leftside_str +=b [i ][j] ;
- for ( int j= ++ ch_place ; j <b[i].length() ; j++ )
- rigthside_str + = b[i] [j] ;
- leftside = atoi(leftside_str. c_str ()) ;
- rigthside = atoi(rigthside_str. c_str ()) ;
- c[i] = leftside % rigthside;
- }
- }
- for(int i=0; i<=a;i++)
- cout<<c[i]<<"\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement