- #include<iostream>
- #include<cstring>
- #define MAX_LEN 400
- using namespace std;
- int a1[MAX_LEN+10];
- int a2[MAX_LEN+10];
- int b1[MAX_LEN+10];
- int b2[MAX_LEN+10];
- char s1[MAX_LEN+10];
- char s2[MAX_LEN+10];
- int main()
- {
- //2.3566
- //5.36666666
- while(cin>>s1>>s2){
- memset(a1,0,sizeof(a1));
- memset(a2,0,sizeof(a2));
- memset(b1,0,sizeof(b1));
- memset(b2,0,sizeof(b2));
- char *pdot1 = strchr(s1,'.');
- if(pdot1==NULL)
- pdot1 = s1+strlen(s1);
- int i = 0;
- char *p;
- for(p=pdot1+1; *p!='\0'; ++p)
- a2[i++] = *p-'0';
- i = 0;
- for(p=pdot1-1; p>=s1; --p)
- a1[i++] = *p-'0';
- char *pdot2 = strchr(s2,'.');
- if(pdot2==NULL)
- pdot2 = s2+strlen(s2);
- i = 0;
- for(p=pdot2+1; *p!='\0'; ++p)
- b2[i++] = *p-'0';
- i = 0;
- for(p=pdot2-1; p>=s2; --p)
- b1[i++] = *p-'0';
- int sign = 0;
- for(i = MAX_LEN-1; i>=0; --i){
- a2[i] += b2[i];
- if(a2[i]>=10){
- a2[i]-=10;
- if(i==0)
- sign = 1;
- else a2[i-1] +=1;
- }
- }
- a1[0] += sign;
- for(i=0; i<MAX_LEN; ++i){
- a1[i] += b1[i];
- if(a1[i]>=10){
- a1[i] -= 10;
- a1[i+1] += 1;
- }
- }
- bool Isprint = 0;
- for(i=MAX_LEN; i>=0; --i)
- if(Isprint)
- cout<<a1[i];
- else if(a1[i]){
- cout<<a1[i];
- Isprint = 1;
- }
- if(!Isprint)
- cout<<'0';
- Isprint = 0;
- for(i=MAX_LEN-1; i>=0; --i)
- if(a2[i]){
- Isprint = 1;
- break;
- }
- if(Isprint){
- cout<<'.';
- for(int j=0; j<=i; ++j)
- cout<<a2[j];
- }
- cout<<endl;
- memset(s1,0,sizeof(s1));
- memset(s2,0,sizeof(s2));
- }
- //system("pause");
- return 0;
- }