View Code of Problem 8

#include<stdio.h>
int main(){
	int a,k=0,n,l,m1,m2,p;
	scanf("%d",&a);
	char b[a][50];
	int i,j;
	for(i=0;i<a;i++)
	{
		for(j=0;j<50&&b[i][j]!='\0';j++)
		scanf("%c",&b[i][j]);
		printf("\n");
	}
	for(i=0;i<a;i++){
		k=0;
		for(j=0;b[i][j+1]!='\0';j++);
		n=b[i][j];
		if(n==0)
		{
		m1=9;
	    m2=n++; 
	}
	else if(n==9){
		m1=n--;
		m2=0;
	}
	else{
		m1=n--;
		m2=n++;
	}
		for(l=1;l<=12;l++){
			if(l==1||l==3||l==5||l==7||l==8||l==10||l==12)
			{
				for(p=1;p<=31;p++)
				if(p%10==m1||p%10==m2)
				k++;
			}
			else if(l==2){
			for(p=1;p<=28;p++)
			if(p%10==m1||p%10==m2)
			k++;
		}
		else{
			for(p=1;p<=30;p++)
			if(p%10==m1||p%10==m2)
			k++;
		}
		}
		printf("%d",k);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 8