|
|
back to boardwhy wrong? #include <stdio.h> #include <math.h> int a[20]; int count; int main() { scanf("%d", &count); for(int i = 0; i < count; i++) { scanf("%d", &a[i]); }
// Сортировка пузырьком bool t = true; while(t) { t = false; for(int i = 0; i < count-1; i++) { if(a[i] > a[i+1]) { int tmp = a[i]; a[i] = a[i+1]; a[i+1] = tmp; t = true; } } }
int r1 = a[count - 1], r2 = 0; for(int i = count - 2; i >= 0; i--) { if(r1 > r2) r2 += a[i]; else r1 += a[i]; } if(r2 > r1) r1 = r2 - r1; else r1 = r1 - r2; printf("%d\n", r1); return 0; } |
|
|