1001:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 #include<stdio.h> 2 #include<string.h> 3 #include<malloc.h> 4 5 void multiple(char *a,char* b,char* m) 6 { 7 int c[150] = {0}; 8 int l1 = strlen(a),l2 = strlen(b),len; 9 for(int i=0;i<l1+l2-1;i++) 10 { 11 for(int j=0;j<=l1+l2-2-i;j++) 12 { 13 if(j < l1 && l1 < 2+i+j) 14 { 15 c[i] += (a[j]-'0')*(b[l1+l2-2-i-j]-'0'); 16 } 17 } 18 } 19 for(int i=0;i<l1+l2+1;i++) 20 { 21 c[i+1]+=c[i]/10; 22 c[i] = c[i]%10; 23 } 24 for(len = l1+l2;len > 0;len--)// len equals to the length of result -1; 25 { 26 if( c[len] != 0) 27 break; 28 } 29 for(int i=0;i<=len;i++) 30 m[i] = c[len-i] + '0'; 31 } 32 33 void power(char *a,int n,char *p) 34 { 35 strcpy(p,a); 36 for(int i=1;i<n;i++) 37 multiple(a,p,p); 38 } 39 40 int trans(char *a) //return the number of digit after dot and clear 0 at tail 41 { 42 int n = 0,l = strlen(a),m=l-1; 43 for(int i=0;i<l;i++) 44 { 45 if(a[i] == '.') 46 { 47 while(a[m] == '0') 48 { 49 a[m] = '\0'; 50 m--; 51 } 52 n = strlen(a)-i-1; 53 a[i] = '\0'; 54 strcat(a,a+i+1); 55 56 break; 57 } 58 } 59 return n; 60 } 61 62 void addDot(char *a,int n) //add dot at n_th place(count backwards) 63 { 64 if(n == 0) return; 65 int l = strlen(a); 66 if(l>n) 67 { 68 for(int i=0;i<n;i++) 69 { 70 a[l-i] = a[l-i-1]; 71 } 72 a[l-n] = '.'; 73 } 74 else 75 { 76 char b[150] = {0}; 77 b[0] = '.'; 78 memset(b+1,'0',(n-l)*sizeof(char)); 79 strcat(b,a); 80 strcpy(a,b); 81 } 82 } 83 84 int main() 85 { 86 char s[6]; 87 char res[150] = {0}; 88 int n; 89 while(scanf("%s %d",s,&n) == 2) 90 { 91 memset(res,0,150 * sizeof(char)); 92 int k = trans(s); 93 power(s,n,res); 94 addDot(res,n*k); 95 printf("%s\n",res); 96 } 97 return 0; 98 }