Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void ispisRimski (int n)
- {
- string Stotice[]={"c","cc","ccc","cd","d","dc","dcc","dccc","cm","m"};
- string Jedinice[] = {"i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"};
- string Desetice[] = {"x","xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc"};
- if (n<10) cout<<Jedinice[n-1];
- if (n%10==0 && n<100) cout<<Desetice[n/10-1];
- if (n%10!=0 && n>10 && n<100) cout<<Desetice[n/10-1]<<Jedinice[n%10-1];
- if (n%100==0) cout<<Stotice[n/100-1];
- 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];
- if (n%100!=0 && n>100 && n%10!=0 && n%100/10==0) cout<<Stotice[n/100-1]<<Jedinice[((n%100)%10)-1];
- if (n%100!=0 && n>100 && n%10==0 ) cout<<Stotice[n/100-1]<<Desetice[((n%100)/10)-1];
- }
- int main()
- {
- int a;
- cout<<"Unesi broj:"<<endl;
- cin>>a;
- ispisRimski(a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement