闰年判断

心得与思路

今天的题也不算太难,写了几分钟就写出来了,我觉得这题最主要的还是判断,如果判断做不好就不行了
代码如下

#include <iostream>
#include <string>
using namespace std;
void main(){
	int n;
	cin>>n;
	int x,y,z;
	x = n % 4;
	y = n%100;
	z = n % 400;
	if(y!= 0){
		if ( x == 0|| z == 0){
			cout<<"yes";
		}
		else{
			cout<<"no";
		}
	}
	else{
		cout<<"no";
	}
	return ;
}
posted @ 2021-07-11 17:26  柏阳光菜菜  阅读(50)  评论(0)    收藏  举报