結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー Kura
提出日時 2019-02-24 22:08:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 783 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 54,888 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-23 23:10:55
合計ジャッジ時間 3,963 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
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