結果

問題 No.405 ローマ数字の腕時計
ユーザー くれちー
提出日時 2016-08-10 22:08:45
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 370 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 22,912 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 19:02:24
合計ジャッジ時間 848 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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);
      |         ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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 a, 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;
}
0