結果

問題 No.405 ローマ数字の腕時計
ユーザー LogicR_piman
提出日時 2016-09-09 07:30:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 57,408 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 19:04:53
合計ジャッジ時間 1,223 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:11: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |         n += m;
      |         ~~^~~~

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;

int main()
{
	int n, m = 0;
	string s;

	cin >> s;
	cin >> m;

	if (s == "I")			n = 1;
	else if (s == "II")		n = 2;
	else if (s == "III")	n = 3;
	else if (s == "IIII")	n = 4;
	else if (s == "V")		n = 5;
	else if (s == "VI")		n = 6;
	else if (s == "VII")	n = 7;
	else if (s == "VIII")	n = 8;
	else if (s == "IX")		n = 9;
	else if (s == "X")		n = 10;
	else if (s == "XI")		n = 11;
	else if (s == "XII")	n = 12;

	n += m;
	while (n > 12) {
		n -= 12;
	}
	while (n < 1) {
		n += 12;
	}
	

	if (n == 1)			s = "I";
	else if (n == 2)	s = "II";
	else if (n == 3)	s = "III";
	else if (n== 4)	s = "IIII";
	else if (n == 5)	s = "V";
	else if (n == 6)	s = "VI";
	else if (n == 7)	s = "VII";
	else if (n == 8)	s = "VIII";
	else if (n == 9)	s = "IX";
	else if (n == 10)	s = "X";
	else if (n == 11)	s = "XI";
	else if (n == 12)	s = "XII";

	cout << s << endl;

	return 0;

}
0