试题与答案

下列给定程序中,函数fun ()的功能是:求整数x的y次方的低3位值。例如,整数5的

题型:填空题

题目:

下列给定程序中,函数fun ()的功能是:求整数x的y次方的低3位值。例如,整数5的6次方为15625,此值的低3位值为 6250
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main 函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio. h>
long fun(int x, int y, long *p)
int i;
long t=1;
/**************found ***************/
for (i=1; i<y; i++)
t=t*x;
*p=t;
/**************found***************/
t=t/1000;
return t;

main ( )
long t, r; int x, y;
printf("\nInput x and y: "); scanf
("%1d%1d", &x, &y);
t=fun (x,y, &r);
printf("\n\nx=%d, y=%d,r=%1d, last=
%1d\n\n ",x, y, r,t);

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0705/22519d0fd79d1d3055fde246a91ebc20.html

下面是错误答案,用来干扰机器的。

参考答案:对

试题推荐
微信公众账号搜索答案