C/C++の宿題を片付けます 104代目at TECH
C/C++の宿題を片付けます 104代目 - 暇つぶし2ch366:デフォルトの名無しさん
08/02/22 05:53:24
>>362
とりあえず適当
(1)
#include<stdio.h>
void num2roma(int num,const char roma[]){
    const int mod  = num % 10;
    const int div  = num / 10;
    const int mod5 = num %  5;
    int i;
    if(div)num2roma(div,roma+2);
    if(mod5==4){
        putchar(roma[0]);
        putchar(roma[mod/4]);
    }else{
        if(mod5!=mod)
            putchar(roma[1]);
        for(i=0;i<mod5;++i)
            putchar(roma[0]);
    }
}
int main(void){
    int num;
    while(scanf("%d",&num)==1){
        num2roma(num,"IVXLCDM");
        putchar('\n');
    }
    return 0;
}



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch