結果

問題 No.405 ローマ数字の腕時計
コンテスト
ユーザー a2011404
提出日時 2017-03-22 16:50:11
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 567 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 109 ms
コンパイル使用メモリ 31,876 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-08 16:10:06
合計ジャッジ時間 871 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:17: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[5]’ [-Wformat=]
   12 |         scanf("%s %d", &si,&t);
      |                ~^      ~~~
      |                 |      |
      |                 char * char (*)[5]
main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%s %d", &si,&t);
      |         ^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

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

			
int main(void) {			

	int i,t,ans=0;
	char si[5],moji[12][5]={"I","II","III","IIII",
			"V","VI","VII","VIII",
			"IX","X","XI","XII"};		
			
	scanf("%s %d", &si,&t);		
	for (i = 0; i < 12; i++) {
		if(0 == strcmp(si,moji[i]))	break;
	}

//	printf("%s %d\n",si,t);	
//	printf("%d\n",i+1);	



	if((i+1+t%12)>=0){
		ans=(i+1+t%12)%12;
//		printf("%d\n",(i+1+t%12)%12);	
	}else{
//		printf("%d\n",(i+1+t%12)%12+12);	
		ans=(i+1+t%12)%12+12;
	}

	if(ans!=0)	printf("%s",moji[ans-1]);
	else		printf("XII");
	return 0;		
}			
0