这是流程图的链接:http: //i1146.photobucket.com/albums/o530/HTHVampire/C%20plus%20plus/Capture_zps5a6c3acf.jpg
下面是流程图的代码如图所示,忽略流程图中的模棱两可的语句。
#include <iostream>
using namespace std;
int main()
{
//declare and initialize a variable
int a = 0;
//prompt user for a value
cout << "please enter a value" << endl;
cin >> a;
again1:
//enter a decision block
if(a > 10)
{
if(a < 10)
{
again2:
if(a < 100)
{
a = a - 3;
goto again2;
}
else goto again1;
}
else
{
a = a - 7;
goto again1;
}
}
else cout << "the output is " << a << endl;
return 0;
}
我可以知道我可以用 if-else 语句和 while 语句来播放这段代码吗?而不是 goto 语句。
感谢您的指导!