题目链接:https://leetcode-cn.com/problems/can-make-arithmetic-progression-from-sequence/
题目如下:
class Solution {
public:
bool canMakeArithmeticProgression(vector<int>& arr) {
if(arr.size()<=2) return true;
int temp=0;
for(int i=0;i<arr.size()-1;i++){
for(int j=i+1;j<arr.size();j++){
if(arr[i]>arr[j]){
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(int i=0;i<arr.size()-2;i++){
if(arr[i]-arr[i+1]==arr[i+1]-arr[i+2]) ;
else return false;
}
return true;
}
};