結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー KuraKura
提出日時 2019-02-24 22:08:31
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 783 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 54,684 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-06 09:02:26
合計ジャッジ時間 3,649 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=]
    5 |         scanf("%d/%d/%d", x, y, z);
      |                ~^         ~
      |                 |         |
      |                 int*      int
main.cpp:5:20: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘int’ [-Wformat=]
    5 |         scanf("%d/%d/%d", x, y, z);
      |                   ~^         ~
      |                    |         |
      |                    int*      int
main.cpp:5:23: warning: format ‘%d’ expects argument of type ‘int*’, but argument 4 has type ‘int’ [-Wformat=]
    5 |         scanf("%d/%d/%d", x, y, z);
      |                      ~^         ~
      |                       |         |
      |                       int*      int
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d/%d/%d", x, y, z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:5:14: warning: ‘x’ is used uninitialized [-Wuninitialized]
    5 |         scanf("%d/%d/%d", x, y, z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:5:14: warning: ‘y’ is used uninitialized [-Wuninitialized]
main.cpp:5:14: warning: ‘z’ is used uninitialized [-Wuninitialized]

ソースコード

diff #

#include<iostream>
using namespace std;
int main() {
	int x, y, z;
	scanf("%d/%d/%d", x, y, z);
	if (y != 2) {
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			z += 2;
			if (z > 30) {
				z -= 30;
				y += 1;
			}
		}
		else {
			z += 2;
			if (z > 31) {
				z -= 31;
				y += 1;
				if (y == 13) {
					y = 1;
					x += 1;
				}
			}
		}
	}
	else {
		if (x % 4 == 0) {
			z += 2;
			if (x % 100 == 0 && x % 400 != 0) {
				if (z > 28) {
					z -= 28;
					y++;
				}
			}
			else {
				if (z > 29) {
					z -= 29;
					y++;
				}
			}
		}
		else {
			z += 2;
			if (z > 28) {
				z -= 28;
				y++;
			}
		}
	}
	cout << x << '/';
	if (y < 10) {
		cout << 0 << y << '/';
	}
	else {
		cout << y << '/';
	}
	if (z < 10) {
		cout << 0 << z << endl;
	}
	else {
		cout << z << endl;
	}
}
0