// con1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; // Note that I was not careful reading the problem statement. I print out the index of // the location in the list with the maximum absolute difference between consecutive pairs // of numbers. The problem statement asked for the two elements. int main() { int i, inputNum, prev, max=-1; int diff, idxOfMaxDiff; // cout cin >> prev; for (i = 1; i < 10; i++) { // I know index start 1 .... //cout cin >> inputNum; // abs difference if (prev - inputNum < 0) diff = inputNum - prev; else diff = prev - inputNum; // alternative: // diff = abs(prev-inputNum); // see if abs dif > max so far if (diff > max) { max = diff; // if so, save index idxOfMaxDiff = i; } // keep prev val prev = inputNum; } return 0; }