mercredi 26 juillet 2017

Why this code is not accepted?

See the image to know what the solution is supposed to do http://ift.tt/2v9ggGS This is my code:

include

include

using namespace std; int main() { int n,last=1,first=0,dif=500,first_,last_; cin >> n; int item[n]; for (int i=0 ; i> item[i]; } sort(item, item + n); while (last <= n){ if((item[last]- item[first]) <= dif){ first_= item[first]; last_ = item[last]; dif = item[last]- item[first]; first++; last++; } else { first++; last++; } } cout << first_ << " " << last_ ; return 0; }

Aucun commentaire:

Enregistrer un commentaire