problem statement is here ...http://ace.delos.com/usacoprob2?
a=1Y1oN7wDfb5&S=friday
and my solution works well in my borland compiler what's
error.....source code is .......
#include<stdio.h>
int leapyear(int year){
if((year%100)==0){
if((year%400)==0)
return 1;
else
return 0;
}
else if(year%4==0){
return 1;
}
else{
return 0;
}
}
int main(){
int leap[]={31,29,31,30,31,30,31,31,30,31,30,31};
int notleap[]={31,28,31,30,31,30,31,31,30,31,30,31};
int day[7]={0,0,0,0,0,0,0};
int i,j,k;
long unsigned int d=2;
FILE * fin=fopen("friday.in","r");
FILE * fout=fopen("friday.out","w");
char ch;
int f=0;
ch=fgetc(fin);
while(ch!=EOF){
f+=(((int)ch)-48);
f*=10;
ch=fgetc(fin);
}
f/=10;
for(i=0;i<f;i++){
if(leapyear(1900+i)){
for(k=0;k<12;k++){
for(j=1;j<=leap[k];j++){
if(j==13){
day[d%7]+=1;
}
d++;
}
}
}
else{
for(k=0;k<12;k++){
for(j=1;j<=notleap[k];j++){
if(j==13){
day[d%7]+=1;
}
d++;
}
}
}
}
-
for(i=0;i<7;i++){
fprintf(fout,"%d ",day[i]);
} fprintf(fout,"\n");
fclose(fin);
fclose(fout);
return 0;
}
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en.