帮我看看这个C++代码为什么会一直循环.我明明写入了"while(z!=3)才循环也就是说等于3就中止循环"..
//filename:d.cpp#include<iostream>usingnamespacestd;voidx();inty();intmain()//声明函数.{i...
//file name:d.cpp
#include <iostream>
using namespace std;
void x();
int y();
int main()//声明函数.
{
int z=0;
while(z!=3)
{
x();
int z;//定义变量.
z=y();
switch(z)
{
case 1:
cout<<"processing receivable"<<endl;
break;
case 2:
cout<<"processing payables"<<endl;
break;
case 3:
cout<<"quitting"<<endl;
break;
default:
cout<<"\alnvalid selection"<<endl;
}
}
return 0;
}
void x()
{
cout<<"---menu---"<<endl;
cout<<"1=receivables"<<endl;
cout<<"2=payables"<<endl;
cout<<"3=ouit"<<endl;
}
int y()
{
int a;
cout<<"enter selection:";
cin>>a;
return a;
} 展开
#include <iostream>
using namespace std;
void x();
int y();
int main()//声明函数.
{
int z=0;
while(z!=3)
{
x();
int z;//定义变量.
z=y();
switch(z)
{
case 1:
cout<<"processing receivable"<<endl;
break;
case 2:
cout<<"processing payables"<<endl;
break;
case 3:
cout<<"quitting"<<endl;
break;
default:
cout<<"\alnvalid selection"<<endl;
}
}
return 0;
}
void x()
{
cout<<"---menu---"<<endl;
cout<<"1=receivables"<<endl;
cout<<"2=payables"<<endl;
cout<<"3=ouit"<<endl;
}
int y()
{
int a;
cout<<"enter selection:";
cin>>a;
return a;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询