#include <iostream> #include <cmath> using namespace std; int main() { int number; cin >> number; if (number < 2) return 0; int front; cin >> front; int after; cin >> after; int temp = after; int min = abs(front-after); //cout << min << endl; number = number - 2; while (number--) { int temp2; cin >> temp2; if (abs(temp2 - temp)< min) { //cout << abs(temp2 - temp) << endl; min = abs(temp2 - temp); front = temp; after = temp2; } temp = temp2; } cout << front <<" "<< after << endl; system("pause"); return 0; }
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务