View Code of Problem 8

#include<stdio.h>
#include<string.h>
int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
	int n,l,cnt;
  	char str[1000];
  	scanf("%d",&n);
  	while(n--){
  		scanf("%s",str);
          	l=strlen(str);
          	cnt=0;
          	for(int i=0;i<12;i++){
                  	for(int j=1;j<=mon[i];j++){
                  		if((str[l-1]-'0')==(j-1)%10 || (str[l-1]-'0')==(j+1)%10)
                                  	cnt++;
                        }
                }
          	printf("%d\n",365-cnt);
        }
  	return 0;
}

Double click to view unformatted code.


Back to problem 8