条件:数据量较小
题解:
题解:
该日期是今年的第几天?+第几天的日期是什么(两个逆运算)
来解决问题。//判断平年还是闰年
bool IsLeapYear(int year){
return (year%4==0 && year%100!=0)||(year%400==0);
}
//平年闰年天数
int NumberOfYear(int year){
if(IsLeapYear(year)){
return 366;
}
else{
return 365;
}
}
int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool check(int year,int month,int day)
{
if(month==0||month>12) return false;
if(day==0) return false;
if(month!=2)
{
if(day>days[month]) return false;
}
else
{
int flag = (year%100&&year%4==0||year%400==0); //能被4整除,不能被100整除,能被400整除
if(day>28+flag) return false; //闰年的2月有29天
}
return true;
}
int main(){
int year,month,day;
while(cin>>year>>month>>day){
int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int flag = 0;
int sumDays = 0;
if(year%4==0&&year%100||year%400==0) flag = 1;
if(flag == 1) days[2]+=1;
for(int i=1;i<month;i++){
sumDays+=days[i];
}
sumDays+=day;
cout<<sumDays<<endl;
}
return 0;
}
int y = 0, product = 1;
while(x){
y+=(x%10)*product;
x/=10;
product*=p;
}
int z[40], num = 0;
do{
z[num++] = y%Q;
y/=Q;
}while(y); //z数组从高位z[num-1]到低位z[0]即为Q进制z