Advertisement
Guest User

Untitled

a guest
May 24th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void ispisRimski (int n)
  6. {
  7. string Stotice[]={"c","cc","ccc","cd","d","dc","dcc","dccc","cm","m"};
  8. string Jedinice[] = {"i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"};
  9. string Desetice[] = {"x","xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc"};
  10. if (n<10) cout<<Jedinice[n-1];
  11. if (n%10==0 && n<100) cout<<Desetice[n/10-1];
  12. if (n%10!=0 && n>10 && n<100) cout<<Desetice[n/10-1]<<Jedinice[n%10-1];
  13. if (n%100==0) cout<<Stotice[n/100-1];
  14. if (n%100!=0 && n>100 && n%10!=0 && n%100/10!=0) cout<<Stotice[n/100-1]<<Desetice[((n%100)/10)-1]<<Jedinice[((n%100)%10)-1];
  15. if (n%100!=0 && n>100 && n%10!=0 && n%100/10==0) cout<<Stotice[n/100-1]<<Jedinice[((n%100)%10)-1];
  16. if (n%100!=0 && n>100 && n%10==0 ) cout<<Stotice[n/100-1]<<Desetice[((n%100)/10)-1];
  17.  
  18.  
  19. }
  20.  
  21. int main()
  22. {
  23. int a;
  24. cout<<"Unesi broj:"<<endl;
  25. cin>>a;
  26. ispisRimski(a);
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement