字符串例题(String examples)
Find the sum of 2 floating points
There are the following forms of floating-point numbers in the input and output:
P1P2... ... Qj
For integer parts, P1P2... Pi is a nonnegative integer
For the decimal part, Qj is not equal to 0
About input
The first line is the N group test data, each test data accounted for 2, respectively, two addends. There is a blank line between each test data, each line of data is not more than 100 characters
About output
N row, each test data has one line output is corresponding and. Output a floating-point number that must be guaranteed to be a decimal fraction that is not 0
Example input
Two
**********
**********
Example output
Ten million and two point one
#include<iostream>
#include<>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
#include<fstream>
Using namespace std;
Void Jia (char str1[], char str2[]);
Int num[100] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Int main ()
{
Int i = 0, j = 0, n = 0, d = 0, nu[26] = {0}, m[1000] = {0};
Char ch[100][100], ch2[100][100];
Cin>>n;
For (I = 0; I < n; i++)
{memset (ch[i],'\0', 100), memset (ch2[i],'\0', 100);
Cin>>ch[i]>>ch2[i];
}
For (I = 0; I < n; i++)
Jia (ch[i], ch2[i]),
Cout<<endl;
Return 0;
}
Void Jia (char str1[], char str2[])
{
Int i = 0, LC = 0, d = 0, l[5] = {0};
Char ch[123];
While (str1[i]! = '.')
I++;
L[1] = I + 1;
L[3] = strlen (STR1) - l[1];
I = 0;
While (str2[i]! = '.')
I++;
L[2] = I + 1;
L[4] = strlen (STR2) - l[2];
LC = (l[1] > l[2]? L[1]: l[2]) + 1;
L[0] = l[3] > l[4]? L[3]: l[4];
Memset (CH,'\0', 123);
For (I = l[0] - 1; I > = 0; i--)
{
If (str1[l[1] + i] ='\0'|| str2[l[2] + i] = ='\0')
Ch[lc + i] = ch[lc + i] + str1[l[1] + i] + str2[l[2] + i];
Else
{
If (str1[l[1] + i] - 2 *'0'+ str2[l[2] + i] + ch[lc + i] > 9)
{
字符串例题(String examples) 来自淘豆网m.daumloan.com转载请标明出处.