求X的Y次方幂C语言代码

如题所述

(1)for语句后边是不加分号的。
(2)在for循环中,结束条件如果是i<=y,前边s的初值应该是1。

#include<stdio.h>
void main()
{
int x,y,i,s;
scanf("%d,%d",&x,&y);
s=1; // s
for(i=1;i<=y;i++) //无分号
s=s*x;
printf("%d",s);
}

运行结果:
4,5
1024Press any key to continue
温馨提示:答案为网友推荐,仅供参考