Habsburg

Peti

Apr 20th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. using namespace std;
  4.  
  5. int main() {
  6.     string R;
  7.     string S;
  8.     bool nijeBroj = false;
  9.     do {
  10.         nijeBroj = false;
  11.         cout << "Upisite R: ";
  12.         cin >> R;
  13.         cout << "Upisite S: ";
  14.         cin >> S;  
  15.         for(int i = 0; i < R.length(); ++i) {
  16.             if(!isdigit(R[i]))
  17.                 nijeBroj = true;
  18.         }
  19.         for(int i = 0; i < S.length(); ++i) {
  20.             if(!isdigit(S[i]))
  21.                 nijeBroj = true;
  22.         }
  23.     }while(nijeBroj);
  24.    
  25.     int r;
  26.     int s;
  27.     istringstream c1(R);
  28.     c1 >> r;
  29.     istringstream c2(S);
  30.     c2 >> s;
  31.    
  32.     if(r >= s) {
  33.         cout << r << " " << s;
  34.     } else
  35.         cout << s << " "  << r;
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment