結果

問題 No.405 ローマ数字の腕時計
ユーザー ElkElk
提出日時 2018-05-23 15:24:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,041 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 26,840 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 01:46:56
合計ジャッジ時間 1,642 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:44: warning: ‘S_time’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     int tmp[5], T, i = 0, wp = 0, wp2 = 0, S_time, mod;
                                            ^~~~~~

ソースコード

diff #

#include<stdio.h>
#include<string.h>

int main(){
    char S1[5];
    int tmp[5], T, i = 0, wp = 0, wp2 = 0, S_time, mod;
    char CLK[12][5] = {"I", "II", "III", "IIII", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"};

    while(1){
        scanf("%c", &tmp[wp++]);
        if((tmp[wp - 1] == 'I') | (tmp[wp - 1] == 'V') | (tmp[wp - 1] == 'X')){
            S1[wp2++] = (char)tmp[wp - 1];
            //printf("S1 %c\n", S1[wp2 - 1]);
        }else{
            S1[wp2] = '\0';
            scanf("%d", &tmp[--wp]);
            wp++;
            T = tmp[wp - 1];
            //printf("T %d\n", T);
            break;
        }
    }
    //printf("S1: %s CLK[11]: %s\n", S1, CLK[11]);
    for(i = 0; i < 12; i++){
        if(strcmp(CLK[i], S1) == 0){
            S_time = i + 1;
            //printf("S_time %d\n", S_time);
        }
    }
    mod = T%12;
    //printf("mod: %d\n", mod);
    if(mod >= 0){
        printf("%s\n", CLK[S_time + mod - 1]);
    }else{
        printf("%s\n", CLK[S_time + mod + 12 - 1]);
    }

    return 0;
}
0