|
|
вернуться в форумwhats wrong in this solution question number 1005 #include <stdio.h> int main() { int number; int b; int weight; int sum; int sum1; int i; int k; int p; int a[20]; status: scanf("%d", &number); if(number>=1&&number<=20) { for(weight=0;weight<number;weight++) { scanf ("%d", &b); if(b>=1&&b<=100000) a[weight]=b; else weight--; } for(i=0;i<number;i++) { for(weight=0;weight<number;weight++) { if(a[weight]>a[weight+1]) { p=a[weight]; a[weight]=a[weight+1]; a[weight+1]=p; } } } sum=a[number-1]; sum1=a[number-2]+a[number-3]; for(i=4;i<=number;i++) { if((sum1+a[number-i])<=sum) sum1=sum1+a[number-i]; else sum=sum+a[number-i]; } k=sum-sum1; printf ("%d\n", k); } else { printf("enter again\n"); goto status; } return 0; } Edited by author 22.12.2011 18:18 |
|
|