编程题目求解4

来源:百度知道 编辑:UC知道 时间:2024/05/16 08:06:40
Description

Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems.

This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.
Input

The input will consist of a set of pairs of values for R and n. The R value will occupy columns 1 through 6, and the n value will be in columns 8 and 9.
Output

The output will consist of one line for each line of input giving the exact value of R^n. Leading zeros should be suppressed in the output. Insignificant trailing zeros must not be printed. Don't print the decimal point if the result is an integer.
Sample Input

95.123 12
0.4321 20
5.1234 15
6.7592 9
98.999 10
1.0100 12

Sample

#include <cstdlib>
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <sstream>

using namespace std;
int stringToDouble(const string & str,double &d)
{
d=0;
int ren=0;
string pre,back;

int size=str.size();
bool falg=true;

for(int i=0;i<size;++i)
{
if(str[i]=='.')
{
falg=false;
continue;
}

if(falg)
{
pre.push_back(str[i]);
}
else
{

back.push_back(str[i]);
}
}