题目链接
Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check has the format “name1price1name2price2…namenpricen”, where namei (name of the i-th purchase) is a non-empty string of length not more than 10, consisting of lowercase English letters, and pricei (the price of the i-th purchase) is a non-empty string, consisting of digits and dots (decimal points). It is possible that purchases with equal names have different prices.

The price of each purchase is written in the following format. If the price is an integer number of dollars then cents are not written.

Otherwise, after the number of dollars a dot (decimal point) is written followed by cents in a two-digit format (if number of cents is between 1 and 9 inclusively, there is a leading zero).

Also, every three digits (from less significant to the most) in dollars are separated by dot (decimal point). No extra leading zeroes are allowed. The price always starts with a digit and ends with a digit.

For example:

“234”, “1.544”, “149.431.10”, “0.99” and “123.05” are valid prices,
“.333”, “3.33.11”, “12.00”, “.33”, “0.1234” and “1.2” are not valid.
Write a program that will find the total price of all purchases in the given bill.

Input
The only line of the input contains a non-empty string s with length not greater than 1000 — the content of the bill.

It is guaranteed that the bill meets the format described above. It is guaranteed that each price in the bill is not less than one cent and not greater than 106 dollars.

Output
Print the total price exactly in the same format as prices given in the input.

Example
Input
chipsy48.32televizor12.390
Output
12.438.32
Input
a1b2c3.38
Output
6.38
Input
aa0.01t0.03
Output
0.04
瓦西里退出了商店,现在他想复查他比尔所有购买的总价格。该汇票是一个字符串,其中的购买和价格的名称打印在一排没有任何空间。检查格式”name1price1name2price2…namenpricen”,在纳美(第i购买的名字)是一个非空字符串的长度不能超过10个,由小写英文字母、和孪斑(第i购买价格)是一个非空字符,包括数字和点(小数点)。有可能购买相同的名称有不同的价格。
每次购买的价格都是按以下格式写的。如果价格是整数美元,那么美分就不写了。
否则,历经多少美元一点(小数点)是其后写美分两位数格式(如果数量在1和9美分,因此,有一个前导零)。
此外,每三位数字(从最不到最重要的)在美元是分开的点(小数点)。没有多余的前导零是允许的。价格总是以一个数字开始,以一个数字结束。
例如:
“234”、“1.544”、“149.431.10”、“0.99”和“123.05”都是有效的价格,
“333”、“3.33.11”、“12”、“33”、“0.1234”和“1.2”是无效的。
写一个程序,在给定的账单上找到所有购买的总价格。
输入
输入的唯一行包含长度不大于1000的非空字符串s,即内容。
保证票据符合上述格式。保证汇票中的每项价格不少于一美分,不大于106美元。
输出
以与输入中的价格相同的格式打印总价格。

#include<bits/stdc++.h>
using namespace std;
char s[1010],a[1010],p[1020];
int a1,a2;//a1是整数部分,a2是小数部分
int tot;
void cal()
{
    //cout<<"*"<<tot<<endl;
   // printf("%s\n",a+1);
     if(a[tot-2]=='.')//特殊处理小数部分
     {
         a2+=((a[tot-1]-'0')*10+(a[tot]-'0'));
         tot-=3;
     }
     if(a2>=100)a2-=100,a1++;//小数的进位
     int sum = 0;
     for(int i=1;i<=tot;i++)
    {
         if(a[i]!='.')sum = sum*10+a[i]-'0';
         //cout<<" "<<sum<<endl;
    }
    a1+=sum;
   // cout<<a1<<endl;
 // cout<<" "<<a2<<endl;
}
int main()
{
     scanf("%s",s+1);
     int len = strlen(s+1);
    //从1开始读入,方便后面i-1不用判越界
     for(int i=1;i<=len;i++)
     {
         if((s[i]<'0'||s[i]>'9')&&s[i]!='.')
            continue;
        //如果当前是字母,则不统计
        if((s[i-1]<'0'||s[i-1]>'9')&&s[i-1]!='.')
        {
            cal();//如果前一个是字母,则进行累加
         // cout<<i<<endl;
            memset(a,0,sizeof(a));//分割计数字符串置零
            tot =0 ;
        }
         a[++tot] = s[i];//数字和.加入分割计数字符串中
         if(i==len)cal();//最后结束时也要统计一次
     }
    int np=0;
     if(a1==0)np=1,p[1]='0';//数字为0时特判加入数字0
     else
     {
         int tmp =0 ;
         while(a1>0)
         {
              p[++np] = a1%10+'0';
             tmp++;
              if(tmp==3)
              {
                  p[++np]='.';//计数加入,
                 tmp =0 ;
              }
              a1/=10;
         }
     }
     if(p[np]!='.')printf("%c",p[np]);//特判开头是.的情况
     for(int i=np-1;i>=1;i--)
        printf("%c",p[i]);
     if(a2)printf(".%02d",a2);//特殊处理小数点
     return 0;
}