理解错了别砸我~~
#include<iostream>
using namespace std;
void main()
{
int strength(0),jump(0),p(0),temp(0);
bool x(1);
cout<<\"Please enter P(1~150000):\t\";
while(1)
{
cin>>p;
if(p>=1 && p<=150000) break;
cout<<\"Overflow!!\nPlease reenter P(1~150000):\t\";
}
for(int i=0;i<p;i++)
{
cout<<\"Please enter strength(1~500) \"<<i+1<<\":\t\";
while(1)
{
cin>>strength;
if(strength>=1 && strength<=500) break;
cout<<\"Overflow!!\nPlease reenter strength(1~500) \"<<i+1<<\":\t\";
}
if(x)
{
if(strength<temp)
{
jump+=temp;
x=0;
}
else if(i==p-1) jump+=strength;
}
else
{
if(strength>temp)
{
jump-=temp;
x=1;
if(i==p-1) jump+=strength;
}
}
temp=strength;
}
cout<<\"The maximum possible jump is \"<<jump<<endl;
}