标签:and tar style name ber turn job 数据 otto
# include <stdio.h> # include <string.h> # include <stdlib.h> # include <iostream> # include <fstream> # include <vector> # include <queue> # include <stack> # include <map> # include <math.h> # include <algorithm> using namespace std; # define pi acos(-1.0) # define mem(a,b) memset(a,b,sizeof(a)) # define FOR(i,a,n) for(int i=a; i<=n; ++i) # define For(i,n,a) for(int i=n; i>=a; --i) # define FO(i,a,n) for(int i=a; i<n; ++i) # define Fo(i,n,a) for(int i=n; i>a ;--i) typedef long long LL; typedef unsigned long long ULL; char a[1000+5],b[1000+5],c[1000+5]; int main() { int t,sum=0; cin>>t; while(t--) { if(sum)cout<<endl; char str1[1000+5],str2[1000+5]; mem(a,‘\0‘); mem(b,‘\0‘); mem(c,‘\0‘);//因为多组数据,所以清零 cin>>str1; for(int i=sizeof(a),j=strlen(str1)-1; j>=0; j--,i--) a[i]=str1[j]-48; cin>>str2; for(int i=sizeof(b),j=strlen(str2)-1; j>=0; j--,i--)//将字符串放在数组末尾,并且将字符转换成ASCLL码所对应的数字 b[i]=str2[j]-48; int num=0,i; for(i=sizeof(a); i>0; i--) { c[i]=a[i]+b[i]+num; num=c[i]/10; c[i]%=10; } printf("Case %d:\n%s + %s = ",++sum,str1,str2); for(i=0;i<=10005;i++)if(c[i])break; for(int j=i; j<=sizeof(c); j++) printf("%d",c[j]);//将大数表示出来 cout<<endl; } return 0; }
HDU 1002 A - A + B Problem II (大数问题)
标签:and tar style name ber turn job 数据 otto
原文地址:http://www.cnblogs.com/teble/p/7192089.html