View Code of Problem 8

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
 
int main() {
	int n;
	scanf("%d",&n);
	char a[1000];
	int k,sum;
	while(n--){
		scanf("%s",&a);
		k=strlen(a);
		k=a[k-1]-'0';
		if(k==0)	sum=287;
		else if(k==1)	sum=294;
		else if(k==2)	sum=286;
		else if(k==3)	sum=293;
		else if(k==4)	sum=293;
		else if(k==5)	sum=293;
		else if(k==6)	sum=293;
		else if(k==7)	sum=293;
		else if(k==8)	sum=294;
		else if(k==9)	sum=294;

		printf("%d\n",sum);
	}
	
}

Double click to view unformatted code.


Back to problem 8