Advertisement
bignose22

Num romanos

Sep 24th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<string.h>
  5. #include<string>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     char nr1[15], nr2[15], op,rnr1[15];
  11.     int nd1=0, nd2=0, tnr1=0, tnr2=0,i=0,j=0;
  12.    
  13.     cout<<"Digite um numero romano: "<<endl;
  14.     cin>>nr1;
  15.    
  16.     tnr1=strlen(nr1);
  17.    
  18.     for(i=1;i<=tnr1;i++)
  19.     {
  20.         if(strcmp(nr1,"I")==0)
  21.         {
  22.             nd1=nd1+1; 
  23.         }
  24.         if(strcmp(nr1,"V")==0)
  25.         {
  26.             nd1=nd1+5;
  27.         }
  28.         if(strcmp(nr1,"X")==0)
  29.         {
  30.             nd1=nd1+10;
  31.         }
  32.        
  33.         if(strcmp(nr1,"L")==0)
  34.         {
  35.             nd1=nd1+50;
  36.         }
  37.         if(strcmp(nr1,"C")==0)
  38.         {
  39.             nd1=nd1+100;
  40.         }
  41.         if(strcmp(nr1,"D")==0)
  42.         {
  43.             nd1=nd1+500;
  44.         }
  45.         if(strcmp(nr1,"M")==0)
  46.         {
  47.             nd1=nd1+1000;
  48.         }
  49.     }
  50.     cout<<"valor final "<<nd1<<endl;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement