#include <stdio.h>
int main()
{
char in1[15],in2[15];
int i,num1,num2;
while(scanf("%s",in1)!=EOF){
if(in1[0]=='#')break;
scanf("%s",in2);
i=0;
num1=0;
num2=0;
while(i<15){
switch(in1[i]){
case 'I':
if(in1[i+1]=='V'|in1[i+1]=='X'){num1-=1;}
else{num1+=1;}
break;
case 'V':
num1+=5;
break;
case 'X':
if(in1[i+1]=='L'|in1[i+1]=='C'){num1-=10;}
else{num1+=10;}
break;
case 'L':
num1+=50;
break;
case 'C':
if(in1[i+1]=='D'|in1[i+1]=='M'){num1-=100;}
else{num1+=100;}
break;
case 'D':
num1+=500;
break;
case 'M':
num1+=1000;
break;
}
i++;
}
i=0;
while(i<15){
switch(in2[i]){
case 'I':
if(in2[i+1]=='V'|in2[i+1]=='X'){num2-=1;}
else{num2+=1;}
break;
case 'V':
num2+=5;
break;
case 'X':
if(in2[i+1]=='L'|in2[i+1]=='C'){num2-=10;}
else{num2+=10;}
break;
case 'L':
num2+=50;
break;
case 'C':
if(in2[i+1]=='D'|in2[i+1]=='M'){num2-=100;}
else{num2+=100;}
break;
case 'D':
num2+=500;
break;
case 'M':
num2+=1000;
break;
}
i++;
}
num1-=num2;
if(num1<0){num1*=-1;}
if(num1==0){printf("ZERO");}
while(num1>=1000){num1-=1000;printf("M");}
while(num1>=900){num1-=900;printf("CM");}
while(num1>=500){num1-=500;printf("D");}
while(num1>=400){num1-=400;printf("CD");}
while(num1>=100){num1-=100;printf("C");}
while(num1>=90){num1-=90;printf("XC");}
while(num1>=50){num1-=50;printf("L");}
while(num1>=40){num1-=40;printf("XL");}
while(num1>=10){num1-=10;printf("X");}
while(num1>=9){num1-=9;printf("IX");}
while(num1>=5){num1-=5;printf("V");}
while(num1>=4){num1-=4;printf("IV");}
while(num1>=1){num1-=1;printf("I");}
printf("\n");
}
return 0;
}
WA (line:5)
答案不正確
您的答案為: XIV 正確答案為: XV