Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main(void){
  8.     string c;
  9.     char a[10], b[10];
  10.     int i, s=false, f=0, g, h;
  11.  
  12.     getline(cin, c);
  13.     for(i=0; i<c.length(); i++){
  14.             if(c[i] == ' '){
  15.                     s=true; f=0;
  16.             } else {
  17.                    if(!s){
  18.                           a[f] = c[i]; f++;
  19.                    } else {
  20.                           b[f] = c[i]; f++;
  21.                    }
  22.             }
  23.     }
  24.  
  25.     g = atoi(a); h = atoi(b);
  26.     if(h < 0){
  27.          cout << g << "+(" << h << ")=" << g+h << "\n";
  28.     } else {
  29.          cout << g << "+" << h << "=" << g+h << "\n";
  30.     }
Add Comment
Please, Sign In to add comment