33,311
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <cstdlib>
using namespace std;
const int p1 = 100;
int main()
{
int count = 0;
int p2 = 10,t;
cout << "input t: ";
cin >> t;
while(1)
{
cout << "t = " << t << " p2 = " << p2 << " + " << t << " = " << p2 + t;
p2 = p2 + t;
cout << " p1 - p2 = " << p1 << " - " << p2 << " = " << p1 - p2 ;
count ++;
if( p1 - p2 >= 5 )
{
cout << ">=5 程序继续" << endl;
}
else
{
cout << "<5 程序退出" << endl;
break;
}
}
cout << "the total time is " << count << endl;
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
const int p1 = 100;
int main()
{
int p2 = 10,t;
cout << "input t: ";
cin >> t;
while(1)
{
cout << "t = " << t << " p2 = " << p2 << " + " << t << " = " << p2 + t;
p2 = p2 + t;
cout << " p1 - p2 = " << p1 << " - " << p2 << " = " << p1 - p2 ;
if( p1 - p2 >= 5 )
{
cout << ">=5 程序继续" << endl;
}
else
{
cout << "<5 程序退出" << endl;
break;
}
}
return 0;
}