新手,大家帮忙看看代码
# include <iostream>
int main()
{
int x ,y;
int sum = x;
if (std::cin >> x)
{
if (std::cin >> y)
{
for(int i = 0;i <= y;i++)
sum *= x;
std::cout<<sum<<std::endl;
}else
{
std::cout<<"wrong character y."<<std::endl;
}
}else{std::cout<<"wrong character x."<<std::endl;}
system("pause");
return 0;
}
编译后 说
为什么X 会显示未定义呢?
[解决办法]
sum = x的时候x没初始化