題目描述
二哥當(dāng)了多年的助教吩谦,今天終于要發(fā)工資了!二哥正在高興之際膝藕,得知工資是分兩部分發(fā)放的式廷。第一部分是這學(xué)期的工資,另一部分是之前所有學(xué)期的工資總和束莫。而領(lǐng)取工資時(shí)懒棉,出納員會(huì)問(wèn)二哥,兩部分工資加在一起是多少览绿,如果二哥回答錯(cuò)了,就只能領(lǐng)到這個(gè)學(xué)期的工資之前所有學(xué)期的勞動(dòng)就白費(fèi)了穗慕。
二哥從小道消息得知饿敲,出納員是個(gè)對(duì)數(shù)字敏感的人,不能有一點(diǎn)差錯(cuò)逛绵,所以二哥需要一個(gè)程序來(lái)幫他算出精確的工資總和怀各。
輸入格式
輸入共兩行,每行是一個(gè)十進(jìn)制表示的工資金額(沒(méi)有正負(fù)號(hào)术浪,小數(shù)點(diǎn)后有兩位數(shù)字)瓢对。
輸出格式
輸出共一行,即精確的工資總和(沒(méi)有正負(fù)號(hào)胰苏,小數(shù)點(diǎn)后有兩位數(shù)字)硕蛹。
說(shuō)明
工資金額的有效數(shù)字位數(shù)不超過(guò)200位,并保證有小數(shù)點(diǎn)。
Sample Input
123.45
543.21
Sample Output
666.66
代碼
}
else ABLnth = BLnth;
for(int i=0;i<ABLnth/2;i++)
{
int temp = AB[i];
AB[i] = AB[ABLnth-i-1];
AB[ABLnth-i-1] = temp;
}
for(int i=0; i<ABLnth;i++)
{
cout<<AB[i];
}
}
else{
for(int i=BLnth;i<ALnth;++i)
{
B[i] = '0';
}
int carry = 0;
int AddN=0;
AddN = B[0] - '0' +A[0]-'0';
if(AddN>9)
{
AddN = AddN-10;
carry = 1;
}
else carry =0;
AB[0] = AddN + '0';
AddN = B[1] - '0' +A[1] - '0' + carry;
if(AddN>9)
{
AddN = AddN-10;
carry =1;
}
else carry =0;
AB[1] = AddN+'0';
AB[2] = '.';
for(int i=3;i<ALnth;++i)
{
AddN = B[i] - '0' + A[i] - '0' +carry;
if(AddN>9)
{
AddN = AddN -10;
carry =1;
}
else carry =0;
AB[i] = AddN+'0';
}
if(carry==1)
{
AB[ALnth] = '1';
ABLnth = ALnth+1;
}
else ABLnth = ALnth;
for(int i=0;i<ABLnth/2;i++)
{
int temp = AB[i];
AB[i] = AB[ABLnth-i-1];
AB[ABLnth-i-1] = temp;
}
for(int i=0; i<ABLnth;i++)
{
cout<<AB[i];
}
}
return 0;
}