努力ing
你浪费的今天是昨天死去的人所渴望的明天!!!

 http://acm.hdu.edu.cn/showproblem.php?pid=1002

#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++)
	{
		string str1,str2;
		cin>>str1>>str2;
		int a[1010]={0},b[1010]={0},c[1010]={0};
		int j,k;
		int alen=str1.length();
		int blen=str2.length();
		k=0;
		for(j=alen-1;j>=0;j--) a[k++]=str1[j]-'0';
		k=0;
		for(j=blen-1;j>=0;j--) b[k++]=str2[j]-'0';
		int e=0;
		for(j=0;j<1010;j++){
			int t;
			t=a[j]+b[j]+e;
			c[j]=t%10;
			e=t/10;
		}
		for(j=j-1;j>=0;j--)
			if(c[j]!=0) break;
		cout<<"Case "<<i<<':'<<endl;
		cout<<str1<<" + "<<str2<<" = ";
		for(;j>=0;j--)
			cout<<c[j];
		cout<<endl;
		if(i!=n) cout<<endl;
	}
	return 0;
}

 

posted on 2013-05-30 20:43  努力ing  阅读(134)  评论(0)    收藏  举报