結果
問題 |
No.405 ローマ数字の腕時計
|
ユーザー |
![]() |
提出日時 | 2018-05-23 15:37:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,211 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 24,192 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 19:17:34 |
合計ジャッジ時間 | 1,022 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:17: warning: format ‘%c’ expects argument of type ‘char*’, but argument 2 has type ‘int*’ [-Wformat=] 10 | scanf("%c", &tmp[wp++]); | ~^ ~~~~~~~~~~ | | | | | int* | char* | %d main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%c", &tmp[wp++]); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:16:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%d", &tmp[--wp]); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:32:16: warning: ‘S_time’ may be used uninitialized in this function [-Wmaybe-uninitialized] 32 | if((S_time + mod)%12 > 0){ | ~~~~~~~~^~~~~~
ソースコード
#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((S_time + mod)%12 > 0){ printf("%s\n", CLK[(S_time + mod)%12 - 1]); //printf("aaa\n"); }else if((S_time + mod)%12 == 0){ printf("%s\n", CLK[11]); //printf("bbb\n"); }else{ printf("%s\n", CLK[S_time + mod + 12 - 1]); //printf("ccc\n"); } return 0; }