第十三届蓝桥杯C++ B组 b题
#include<bits/stdc++.h>
using namespace std;
int res;
int m[13]=
{0,31,28,31,30,31,30,31,31,30,31,30,31,
};
bool check(string s)
{for(int i=0;i+2<s.size();i++){if(s[i]+1==s[i+1]&&s[i+1]+1==s[i+2])return true;}return false;
}
int main()
{int year=2022,month=1,day=1;for(int i=0;i<365;i++){// string s;这样写会报错hh.char s[10];sprintf(s,"%04d%02d%02d",year,month,day);if(check(s)){res++;cout<<s<<endl;}if(++day>m[month]){day=1;month++;}}cout<<res<<endl;return 0;
}