ZZULIOJ-1379: A+B

题目描述:

读入两个小于100的正整数A和B,计算A+B的值并输出。 

输入: 

测试为多实例测试,第一行包含一个T,表示测试实例的个数,后面有T行 
每行包含两个数A和B。 

输出: 

对于每组输入,输出A+B的和,单独占一行。要求输出结果用英文单词表示,如整数34表示为three four。测试数据可以保证结果均小于100。 

样例输入: 

2

1 2

5 16 

样例输出: 

three

two one 

程序代码: 

 

#include
#include
char s[20][20]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main()
{
	int a,b,t,x[10];
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d %d",&a,&b);
		int sum=a+b;
		if(sum==0)
		{
			printf("zero\n");
			continue;
		}
		int j=0;
		while(sum)
		{
			x[j++]=sum%10;
			sum/=10;
		}
		for(int i=j-1;i>=0;i--)
		{
			printf("%s ",s[x[i]]);
		}
		printf("\n");
	}
	return 0;
}

 

你可能感兴趣的:(#,简单题)