不知道哪里出错了
#include<stdio.h>long fun(int x,int y,int * p)
{
int i;
long t=1;
for(i=1;i<=y;i++)
t=t*x;
*p=t;
t=t%100;
return t;
}
main()
{
long t,r;
int x,y;
printf("input xy\n");
scanf("%ld%d",&x,&y);
t=fun(x,y,&r); /*D:\Program Files\Microsoft Visual Studio\MyProjects\loveq001\ab111.cpp(18) : error C2664: 'fun' : cannot convert parameter 3 from 'long *' to 'int *'Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\MyProjects\loveq001\ab111.cpp(20) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
ab111.obj - 1 error(s), 0 warning(s)*/
printf("\n\nx=%d,y=%d,y=%ld,last=%ld\n\n",x,y,r,t);
}
求整数x的y的次方的低3位值。例如,例如5的6次方位15625,此值得低3位为625.还有个问题就是为啥是 t=t%100,而不是t=t%1000.
thank you very much.