[C++] hdoj1076简单题 →→→→→进入此内容的聊天室

来自 , 2020-03-28, 写在 C++, 查看 104 次.
URL http://www.code666.cn/view/44a2e080
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. bool is_leap(int year){
  5.         if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)){
  6.                 return true;
  7.         }else{
  8.                 return false;
  9.         }
  10. }
  11.  
  12. int main(){
  13.         int m;
  14.         int year, n;
  15.         int count;
  16.         cin>>m;
  17.         for(int i = 0; i < m; i++){
  18.                 count = 0;
  19.                 cin>>year>>n;
  20.                 for( ; count < n; year++){//注意这里是 count < n,而不是 count <= n
  21.                         if(is_leap(year)){
  22.                                 count++;
  23.                         }
  24.                 }
  25.                 year--;
  26.                 cout<<year<<endl;
  27.         }
  28. }

回复 "hdoj1076简单题"

这儿你可以回复上面这条便签

captcha