View Code of Problem 8

#include<stdio.h>
#include <string.h>
#include <math.h>
int main(){
	int a[5]={287,294,286,293,294};
	char s[100];
	int n,w;
	scanf("%d",&n);
	int i,j;
	for(i=0;i<n;i++)
	{
		scanf("%s",s);
	    j=strlen(s)-1;
	    w=s[j]-'0';
	    switch(w){
	    	case 0:printf("%d\n",a[0]);break;
	    	case 1:printf("%d\n",a[1]);break;
	    	case 2:printf("%d\n",a[2]);break;
	    	case 3:
	    	case 4:
	    	case 5:
	    	case 6:
	    	case 7:printf("%d\n",a[3]);break;
	    	case 8:
	    	case 9:printf("%d\n",a[4]);break;
	    	
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 8