Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. for(int i = 0; i < wej.length(); i++)
  2. {
  3. cin>>wej;
  4. switch(wej[i])
  5. {
  6. case 'M':
  7. if(wej[i-1] == 'C' && i>0){
  8. wyj+=800;
  9. }
  10. else{
  11. wyj+=1000;
  12. }
  13. break;
  14. case 'D':
  15. if(wej[i-1] == 'C' && i>0){
  16. wyj+=300;
  17. }
  18. else{
  19. wyj+=500;
  20. }
  21. break;
  22. case 'C':
  23. if(wej[i-1] == 'X' && i>0){
  24. wyj+=80;
  25. }
  26. else{
  27. wyj+=100;
  28. }
  29. break;
  30. case 'L':
  31. if(wej[i-1] == 'X' && i>0){
  32. wyj+=30;
  33. }
  34. else{
  35. wyj+=50;
  36. }
  37. break;
  38. case 'X':
  39. if(wej[i-1] == 'I' && i>0){
  40. wyj+=8;
  41. }
  42. else{
  43. wyj+=10;
  44. }
  45. break;
  46. case 'V':
  47. if(wej[i-1] == 'I' && i>0){
  48. wyj+=3;
  49. }
  50. else{
  51. wyj+=5;
  52. }
  53. break;
  54. case 'I':
  55. wyj+=1;
  56. break;
  57. default:
  58. wyj+=0;
  59. }
  60. }
  61. cout << "Converted " << wej << " to " << wyj <<".";
  62. break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement