爱奇艺编程题:拼凑正方形

题目:https://www.nowcoder.com/practice/563c6a69fd714e59a942d97047cedcb3?tpId=90&tqId=30796&tPage=2&rp=2&ru=/ta/2018test&qru=/ta/2018test/question-ranking

#include

using namespace std;

int main()

{

int a,b,c,d;

while(cin>>a>>b>>c>>d){

vector num(4);

num[0] = a;

num[1] = b;

num[2] = c;

num[3] = d;

sort(num.begin(),num.begin() + 4);

int mid = (num[1] + num[2]) / 2;

int sum = 0;

for(auto i:num)

sum += abs(i - mid);

cout<

}

    return 0;

}

你可能感兴趣的:(爱奇艺编程题:拼凑正方形)