eduarte @ 2019-03-19 18:57:16
/tmp/tmpkenqhiwb/src: 在函数‘int main()’中: /tmp/tmpkenqhiwb/src:56:15: 警告:在算术表达式中使用了函数指针 [-Wpointer-arith] if(is_leap[i]){ ^
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int pa(int num){
int a,b,c,d;
a=(num/1000)%10;
b=(num/100)%10;
c=(num/10)%10;
d=num%10;
return d*1000+c*100+b*10+a;
}
bool is_pa(int num){
return num/10000==pa(num)?true:false;
}
bool is_date(int date){
int arr[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
if((date/100)%100<=12 && date%100<=arr[(date/100)%100]){
return true;
}
return false;
}
bool is_leap(int year){
if(!year%4 && year%100) return false;
if(!year%400) return true;
return false;
}
bool is_in(int date,int check,bool is_start){
if(is_start){
return date>check?false:true;
}else{
return date<check?false:true;
}
}
int main(){
int start,end;
cin>>start>>end;
if(start==end && is_pa(start)){
cout<<1;
return 0;
}
else if(start==end && !is_pa(start)){
cout<<0;
return 0;
}
int sum = 0;
for(int i=start/10000;i<=end/10000;i++){
if(is_leap[i]){
if(is_date(i*10000+pa(i))){
if(i!=start/10000 && i!=end/10000){
sum++;
}
else if(is_in(i==start/10000?start%10000:end%10000,pa(i),i==start/10000?true:false)){
sum++;
}
}
}
}
cout<<sum;
return 0;
}
by ezoixx118 @ 2019-03-19 19:09:56
因为:
is_leap[i]
中括号改为小括号
by eduarte @ 2019-03-19 22:33:58
@ezoixx118 emmmm