1001WA

时间:2022-03-10 17:32:26

时间关系只实现了其中一部分的功能  现在的程序可以实现一个大数的平方

1001WA

 #include <stdio.h>
#include <string.h>
void mypower(int num2);
int findflag();
int myflag = ;
char num1[];
int num2;
char a[] = {};
char b[] = {};
int c[] = {};
int d[] = {};
int main(void)
{
scanf("%s%d",num1,&num2);
myflag = findflag();
mypower(num2);
return ;
} void mypower(int num2)
{
int i,j,k,s;
for(s = ;s < num2;s++)
{
memset(c,,sizeof(c));
if(b[] == '\0')
{
for(i = ;a[i] != '\0';i++)
{
b[i] = a[i];
}
}
for(i = ;a[i] != '\0';i++)
for(j =;b[j] != '\0';j++)
{
c[i+j] += (a[i] - '') * (b[j] - ''); }
for(k = i+j-;k > ;k--)
{
d[k] = (c[k-] % );
c[k-] += c[k-] /;
}
d[] = (c[] / );
d[] = (c[] % );
if(d[] != )
{
for(k = ;k < i+j;k++)
b[k] = d[k];
}else
{
for(k = ;k < i+j;k++)
b[k-] = d[k];
} }
myflag *= num2;
if(d[] != )
{
for(s =;s < myflag;s++)
{
b[i+j-s] = b[i+j--s];
b[i+j--s] = '.';
}
for(i = ;i<k+;i++)
{
if(b[i] == '.')
{
printf("%c",b[i]);
continue;
}
printf("%d",b[i]);
}
}else
{
for(s =;s < myflag;s++)
{
b[i+j--s] = b[i+j--s];
b[i+j--s] = '.';
}
for(i = ;i<k;i++)
{
if(b[i] == '.')
{
printf("%c",b[i]);
continue;
}
printf("%d",b[i]);
}
} } int findflag()
{
int i,j,flag = ;
for(i = ;num1[i] != '\0';i++)
{
if(num1[i] == '.')
{
flag = i;
continue;
}
a[j++] = num1[i];
}
flag = j - flag;
return flag;
}

相关文章