結果
問題 |
No.405 ローマ数字の腕時計
|
ユーザー |
![]() |
提出日時 | 2016-08-10 22:09:52 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 367 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 23,040 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-06 19:02:30 |
合計ジャッジ時間 | 787 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:10:29: warning: implicit declaration of function ‘abs’ [-Wimplicit-function-declaration] 10 | if (t < 0) t = 12 - abs(t) % 12; | ^~~ main.c:4:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘abs’ 3 | #include <math.h> +++ |+#include <stdlib.h> 4 | main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%s %d", s, &t); | ^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> #include <math.h> int main() { char s[5], rome[12][5] = { "I","II","III","IIII","V","VI","VII","VIII","IX","X","XI","XII" }; int t, i; scanf("%s %d", s, &t); if (t < 0) t = 12 - abs(t) % 12; for (i = 0; i < 12; i++) { if (strcmp(s, rome[i]) == 0) { printf("%s\n", rome[(i + t) % 12]); break; } } return 0; }