请问我要使程序结果显示“程序执行了3次”,以下这个程序当如何修改?

来源:百度知道 编辑:UC知道 时间:2024/05/28 09:45:44
#include<iostream>
using namespace std;
int main()
{
int s=0;
while(1)
{
int n;
cout<<"请输入一个数字:";
cin>>n;
cout<<"您输入的数字是:"<<n<<endl;
s++;
if(s>3)
break;
}
cout<<"程序执行了:"<<s<<endl;
return 0;
}

#include<iostream>
using namespace std;
int main()
{
int s=0;
while(1)
{
int n;
cout<<"请输入一个数字:";
cin>>n;
cout<<"您输入的数字是:"<<n<<endl;
s++;
if(s==2)
break;
}
cout<<"程序执行了:"<<s+1<<endl;
getchar();
getchar();
return 0;
}