第一篇题解:
#include<cstdio>
using namespace std;
int l,n;
int a[201],b[201];
void gjc()
{
int t=0;
for (int j=200;j>0;j--)
{
l=b[j]*2+t;
b[j]=l%10;
t=l/10;
}
}
void gjj()
{
int t=0;
for (int j=200;j>0;j--)
{
l=a[j]+b[j]+t;
a[j]=l%10;
t=l/10;
}
}
int main()
{
scanf("%d",&n);
b[200]=1;
for (int i=1;i<=n;i++)
{gjc();gjj();}
int k=1;
while (a[k]==0&&k<200)
k++;
for (int i=k;i<=200;i++)
printf("%d",a[i]);
return 0;
}
第六篇题解:
#include<cstdio>
using namespace std;
int l,n;
int a[201],b[201];//a是最终结果,b是2的i次方
void gjc()//高精乘,算2的i次方
{
int t=0;
for (int j=200;j>0;j--)
{
l=b[j]*2+t;
b[j]=l%10;
t=l/10;
}
}
void gjj()//高精加,把数组B的值加到A里面
{
int t=0;
for (int j=200;j>0;j--)
{
l=a[j]+b[j]+t;
a[j]=l%10;
t=l/10;
}
}
int main()
{
//freopen("hanoi.in","r",stdin);
//freopen("hanoi.out","w",stdout);
scanf("%d",&n);//读入
b[200]=1;//初值,不能漏掉
for (int i=1;i<=n;i++)
{gjc();gjj();}//运算
int k=1;
while (a[k]==0&&k<200)//去除前导0
k++;
for (int i=k;i<=200;i++)
printf("%d",a[i]);//输出
//fclose(stdin);
//fclose(stdout);
}
如上,这是P1096的第一篇和第六篇题解,可见它们两个极为相似,变量名都一样。只是第六篇题解添加了注释和freopen与fclose语句。这可不可以被判定为抄袭?望解答。