find()函数的使用
基本使用
详细情况点击
https://blog.csdn.net/qq_51271013/article/details/116170964
#include<iostream>
#include<string>
using namespace std;
bool cheak(int year,int month,int day)
{
string str=to_string(year); 把数字2022转化为字符串形式加入该字符串
if(month<10) str+='0';
str+=to_string(month);
if(day<10) str+='0';
str+=to_string(day);
return (str.find("012") != -1)||(str.find("123") != -1); //判断是否含有顺子日期
}
int main()
{
int year=2022;
int i,j;
int ans=0;
int months[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
遍历月份及日期
for(i=1;i<=12;i++)
{
for(j=1;j<=months[i];j++)
{
if(cheak(year,i,j)==true)
{
ans++;
}
}
}
cout<<ans<<endl;
return 0;
}