Untitled
unknown
plain_text
3 years ago
523 B
5
Indexable
#include <iostream>
using namespace std;
int main()
{
int n,c=0,f=0,v = 0;
int mas[101];
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> mas[i];
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n-1; j++)
{
if (mas[j]>mas[j+1])
{
c = mas[j]; mas[j] = mas[j + 1]; mas[j + 1] = c;
}
}
}
for (int i = n / 2; i < n; i++)
{
f += mas[i];
}
for (int i = 0; i < n/2; i++)
{
v += mas[i];
}
if (v > f)
{
cout << v - f;
}
else cout << f - v;
}
Editor is loading...