Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<string>
- using namespace std;
- int main()
- {
- char nr1[15], nr2[15], op,rnr1[15];
- int nd1=0, nd2=0, tnr1=0, tnr2=0,i=0,j=0;
- cout<<"Digite um numero romano: "<<endl;
- cin>>nr1;
- tnr1=strlen(nr1);
- for(i=1;i<=tnr1;i++)
- {
- if(strcmp(nr1,"I")==0)
- {
- nd1=nd1+1;
- }
- if(strcmp(nr1,"V")==0)
- {
- nd1=nd1+5;
- }
- if(strcmp(nr1,"X")==0)
- {
- nd1=nd1+10;
- }
- if(strcmp(nr1,"L")==0)
- {
- nd1=nd1+50;
- }
- if(strcmp(nr1,"C")==0)
- {
- nd1=nd1+100;
- }
- if(strcmp(nr1,"D")==0)
- {
- nd1=nd1+500;
- }
- if(strcmp(nr1,"M")==0)
- {
- nd1=nd1+1000;
- }
- }
- cout<<"valor final "<<nd1<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement