屬基礎題。
P.S. 閏年為可被4但不被100整除的年份,以及會被400整除的年份。
[C++](18ms, 672KB)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main() | |
{ | |
int year; | |
while( cin >> year ) | |
{ | |
if( ( year % 4 == 0 && year % 100 != 0 ) || year % 400 == 0 ) | |
cout << "閏年\n"; | |
else | |
cout << "平年\n"; | |
} | |
return 0; | |
} |
0 意見:
張貼留言