Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. class RzymArab {
  9. private:
  10. static string rzym[13];
  11. static int arab[13];
  12. public:
  13. static int rzym2arab(string);
  14. static string arab2rzym(int);
  15. };
  16.  
  17.  
  18. string RzymArab::rzym[13] = {"I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"};
  19. int RzymArab::arab[13] = {1,4,5,9,10,40,50,90,100,400,500,900,1000};
  20.  
  21. string RzymArab::arab2rzym(int x){
  22. int i=12;
  23. string s="";
  24.  
  25. while(x>=1){
  26. if(x>=arab[i]){
  27. x-=arab[i];
  28. s=s+rzym[i];
  29. }
  30. else
  31. i-=1;
  32. }
  33.  
  34. return s;
  35.  
  36. }
  37.  
  38.  
  39.  
  40.  
  41. int main() {
  42.  
  43. string x;
  44. x=RzymArab.arab2rzym(1164);
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement