循环结束不了,一直在输入。poj1001
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
char s[199]={'\0'};
int n=0,x=0;
while(scanf("%s%d", s, &n) == 2) {
x=0;
int di = 1, num = 0;
int a[1000000];
a[0] = 1;
int t;
int nn[100];
int id = 0;
int count = 0, f = 0;
for (int i = 0; i < strlen(s); ++i) {
if (f) {
id++;
}
if (s[i] == '.') {
f = 1;
} else {
a[count++] = int(s[i] - '0');
}
}
int sq = strlen(s) - 2;
for (int i = 0; i < strlen(s) - 1; ++i) {
x += a[sq--] * powf(10, i);
}
id *= n;
a[0] = 1;
while (n--) {
for (int j = 0; j < di; ++j) {
t = a[j] * x + num;
a[j] = t % 10;
num = t / 10;
}
while (num) {
a[di++] = num % 10;
num /= 10;
}
}
int j = 1;
if (di <= id) {
cout << ".";
for (int i = 0; i < id - di; ++i) {
cout << "0";
}
}
int hhh=0;
for (int i = 0; i < di-1; ++i) {
if(a[i]==0){
hhh++;
}
else break;
}
for (int i = di - 1; i >= hhh+0; --i) {
if (j == di - id + 1) {
cout << ".";
}
j++;
cout << a[i];
}
cout << endl;
}
return 0;
}