讨论 / 为什么在rq老是编译错误(compile error)???
caiweiwenjs 2010-07-21 17:54:00
点我顶贴 收藏 删除
在我的VC++6.0编译通过,而且样例可以过。

在rq编译的结果:

//RQNOJ:UserCode\327724.cpp: In function `int main()’:

//RQNOJ:UserCode\327724.cpp:25: error: `plus’ undeclared (first use this function)

//RQNOJ:UserCode\327724.cpp:25: error: (Each undeclared identifier is reported only once for each function it appears in.)

//RQNOJ:UserCode\327724.cpp: In function `void plus(int*, int*, int*)’:

//RQNOJ:UserCode\327724.cpp:55: error: `void plus(int*, int*, int*)’ used prior to declaration

//RQNOJ:UserCode\327724.cpp:65:2: warning: no newline at end of file

我的的程序:

#include <iostream>

using namespace std;

const int M=10;

const int MAXN=100;

int ans[MAXN]={0},p[MAXN]={0},tmp[MAXN]={0},n,x,a;

void mul(int [],int x,int []);

void plus(int [],int [],int []);

int main()

{

int i;

cin>>x>>n;

cin>>a;

while (a>0)

ans[++ans[0]]=a%M,a/=M;

p[0]=1,p[1]=1;

for (i=0;i<n;i++)

{

cin>>a;

mul(p,x,p);

mul(p,a,tmp);

plus(tmp,ans,ans);

}

if (ans[0]<MAXN)

{

for (i=1;i<=MAXN-ans[0];i++)

cout<<'0';

for (i=ans[0];i>0;i--)

cout<<ans[i];

}

else

for (i=MAXN;i>0;i--)

cout<<ans[i];

cout<<endl;

return 0;

}

void mul(int a[],int b,int c[])

{

int i;

c[0]=a[0];

for (i=1;i<=c[0];i++)

c[i]=a[i]*b;

for (i=1;i<=c[0];i++)

c[i+1]+=c[i]/M,c[i]%=M;

while (c[c[0]]>0)

c[c[0]+1]+=c[c[0]]/M,c[c[0]]%=M,c[0]++;

}

void plus(int a[],int b[],int c[])

{

int i;

c[0]=(a[0]>b[0])? a[0]:b[0];

for (i=1;i<=c[0];i++)

c[i]=a[i]+b[i];

for (i=1;i<=c[0];i++)

c[i+1]+=c[i]/M,c[i]%=M;

while (c[c[0]]>0)

c[c[0]+1]+=c[c[0]]/M,c[c[0]]%=M,c[0]++;

}

#1 sideman@2010-07-20 19:10:00
回复 删除
void mul(int [],int x,int []) 为啥加那个X啊前面x后面变成b了,

另:oi就别用vc6.0了,否则ce了都不知道怎么回事,

#2 caiweiwenjs@2010-07-21 16:29:00
回复 删除
回复 沙发sideman 的帖子

把x改成b也是不行。

谢谢你的指点,因为我原来是用Pascal的,现在要改c++,所以对于c++的一些东西都不是很了解。oi一般都用什么IDE,可以告诉我吗?谢谢!

#3 renqing@2010-07-21 17:22:00
回复 删除
RQNOJ用的是G++,VC可以编译的不保证在RQNOJ上可以编译通过
#4 caiweiwenjs@2010-07-21 17:54:00
回复 删除
回复 地毯renqing 的帖子

谢谢!

查看更多回复
提交回复