Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Why wrong answer ? Who can tell me ? Thank you !!! Codes here please :)

Posted by 123454321 at 2006-07-20 20:51:21 on Problem 2685
```#include<stdio.h>
struct num{
int key;
char mcxi;
};
int deal1(char s[])
{
int k,j,sum;
struct num tem[99];
for(k=0;s[k];k++)
{
if(s[k]=='m'||s[k]=='c'||s[k]=='x'||s[k]=='i')
{
tem[k].key=1;
tem[k].mcxi=s[k];
}
else
{
tem[k].key=s[k]-'0';
tem[k].mcxi=s[k+1];
k+=1;
}
}
sum=0;
for(j=0;j<k;j++)
switch(tem[j].mcxi) {
case 'm' :sum+=tem[j].key*1000;break;
case 'c' :sum+=tem[j].key*100;break;
case 'x' :sum+=tem[j].key*10;break;
case 'i' :sum+=tem[j].key;break;
}
return sum;
}

int main()
{
register int k,j;
int total,sum,sum1,sum2;
char s1[19],s2[19];
struct num d[5];
scanf("%d",&total);
while(total--)
{
scanf("%s%s",s1,s2);
sum1=deal1(s1);
sum2=deal1(s2);
sum=sum1+sum2;
//deal2(sum);
for(k=1;sum>0 && k<5;k++)
{
d[k].key=sum%10;
sum=sum/10;
}
d[1].mcxi='i';
d[2].mcxi='x';
d[3].mcxi='c';
d[4].mcxi='m';
//print();
for(j=k-1;j>0;j--)
if(d[j].key==0) continue;
else if(d[j].key==1) printf("%c",d[j].mcxi);
else printf("%d%c",d[j].key,d[j].mcxi);
printf("\n");

}
return 0;
}
```

Followed by: