neogz

pretvarac u rimske

Nov 20th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4.  
  5.     int broj = 0;
  6.  
  7.     cout << "Unesite broj u intervalu 1-500: ";
  8.     cin >> broj;
  9.    
  10.  
  11.     do
  12.     {
  13.         if (broj <1 || broj >500) cout << "Niste unijeli broj u intervalu 1-500.\n";
  14.         else
  15.         {
  16.             if (broj == 500)    { cout << "D";       broj -= 500; }
  17.             if (broj >= 400)    { cout << "CD";      broj -= 400; }
  18.             if (broj >= 300)    { cout << "CCC";     broj -= 300; }
  19.             if (broj >= 200)    { cout << "CC";      broj -= 200; }
  20.             if (broj >= 100)    { cout << "C";       broj -= 100; }
  21.             if (broj >= 90)     { cout << "XC";      broj -= 90; }
  22.             if (broj >= 80)     { cout << "LXXX";    broj -= 80; }
  23.             if (broj >= 70)     { cout << "LXX";     broj -= 70; }
  24.             if (broj >= 60)     { cout << "LX";      broj -= 60; }
  25.             if (broj >= 50)     { cout << "L";       broj -= 50; }
  26.             if (broj >= 40)     { cout << "XL";      broj -= 40; }
  27.             if (broj >= 30)     { cout << "XXX";     broj -= 30; }
  28.             if (broj >= 20)     { cout << "XX";      broj -= 20; }
  29.             if (broj >= 10)     { cout << "X";       broj -= 10; }
  30.             if (broj >= 9)      { cout << "IX";      broj -= 9; }
  31.             if (broj >= 8)      { cout << "VIII";    broj -= 8; }
  32.             if (broj >= 7)      { cout << "VII";     broj -= 7; }
  33.             if (broj >= 6)      { cout << "VI";      broj -= 6; }
  34.             if (broj >= 5)      { cout << "V";       broj -= 5; }
  35.             if (broj >= 4)      { cout << "IV";      broj -= 4; }
  36.             if (broj >= 3)      { cout << "III";     broj -= 3; }
  37.             if (broj >= 2)      { cout << "II";      broj -= 2; }
  38.             if (broj >= 1)      { cout << "I";       broj -= 1; }
  39.         }
  40.  
  41.         cout << "\n\nUnesite broj u intervalu 1-500: ";
  42.         cin >> broj;
  43.     } while (broj>0);
  44.  
  45.  
  46.  
  47.  
  48.  
  49.     system("pause > nul");
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment