結果
| 問題 | 
                            No.405 ローマ数字の腕時計
                             | 
                    
| コンテスト | |
| ユーザー | 
                             FF256grhy
                         | 
                    
| 提出日時 | 2016-08-05 22:31:29 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 2,000 ms | 
| コード長 | 463 bytes | 
| コンパイル時間 | 183 ms | 
| コンパイル使用メモリ | 22,912 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-06 18:58:25 | 
| 合計ジャッジ時間 | 829 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |         scanf("%s%d", s, &t);
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:35:30: warning: ‘u’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |         printf("%s\n", rm[(u + t + 1200) % 12]);
      |                            ~~^~~
            
            ソースコード
#include <stdio.h>
char rm[12][5] = {
	"XII", 
	"I", 
	"II", 
	"III", 
	"IIII", 
	"V", 
	"VI", 
	"VII", 
	"VIII", 
	"IX", 
	"X", 
	"XI"
};
char s[5];
int t;
bool eq(char a[], char b[]) {
	int i = 0;
	while(a[i] != '\0' && b[i] != '\0' && a[i] == b[i]) { i++; }
	
	return (a[i] == b[i]);
}
int main() {
	scanf("%s%d", s, &t);
	
	int u;
	for(int i = 0; i < 12; i++) {
		if( eq(s, rm[i]) ) { u = i; }
	}
	
	printf("%s\n", rm[(u + t + 1200) % 12]);
	
	return 0;
}
            
            
            
        
            
FF256grhy