[ create a new paste ] login | about

Link: http://codepad.org/OHOFfttD    [ raw code | output | fork ]

C++, pasted on Jul 27:
#include <iostream>

using namespace std;

int WesternToShouwa(int western) {
	if (1926 <= western && western <= 1989) {
		return western - 1925;
	}
	else {
		return 0;
	}
}

void Shouwa() {
	int western;

	cout << "西暦を入力して下さい" << endl;
	cin >> western;

	int shouwa = WesternToShouwa(western);
	if (shouwa == 0) {
		cout << "その年は昭和ではありません" << endl;
	}
	else {
		cout << "その年は昭和" << shouwa << "年です" << endl;
	}
}

int main() {
	Shouwa();
	Shouwa();

	for(;;){}

}


Output:
1
2
3
4
5
6
西暦を入力して下さい
その年は昭和ではありません
西暦を入力して下さい
その年は昭和ではありません

Timeout


Create a new paste based on this one


Comments: