void o(long int out)
{
int i=0;
for(i=0;i<out/1000;i++)
{
cout<<'M';
}
out=out%1000;
if(out>=900)
{
cout<<"CM";
out-=900;
}
if(out>=500)
{
cout<<"D";
out-=500;
}
if(out>=400)
{
cout<<"CD";
out-=400;
}
for(i=0;i<out/100;i++)
{
cout<<'C';
}
out=out%100;
if(out>=90)
{
cout<<"XC";
out-=90;
}
if(out>=50)
{
cout<<"L";
out-=50;
}
if(out>=40)
{
cout<<"XL";
out-=40;
}
for(i=0;i<out/10;i++)
{
cout<<'X';
}
out=out%10;
if(out>=9)
{
cout<<"IX";
out-=9;
}
if(out>=5)
{
cout<<"V";
out-=5;
}
if(out==4)
{
cout<<"IV";
out-=4;
}
for(i=0;i<out;i++)
{
cout<<'I';
}
cout<<endl;
}
int rome(char a)
{
int x;
switch(a)
{
case 'M':
x=1000;
break;
case 'D':
x=500;
break;
case 'C':
x=100;
break;
case 'L':
x=50;
break;
case 'X':
x=10;
break;
case 'V':
x=5;
break;
case 'I':
x=1;
break;
}
return x;
}
兩個是讀取十進制和輸出十進制
#提供無技術含量的
while((a=getchar())!='\n'&&a!=EOF&&a!=' '&&a!='#')
{
while((b=getchar())!='\n'&&b!=EOF&&b!=' ')
{
...
}
while((b=getchar())!='\n'&&b!=EOF&&b!=' ')
{
...
}
請誤直抄
如果想法是同思路的
記得單字元的情況
你會讀不到另一組字母