#include <stdio.h> void main() { int arraysize; scanf("%d", &arraysize); int arr[arraysize]; int sum; int largest; int smallest; for(int i=0; i<arraysize; i++) { scanf("%d",&arr[i]); } for(int i=0; i<arraysize; i++) { for(int n=i+1; n<arraysize; n++) { if(arr[i]>arr[n]) { sum = arr[i]; arr[i]=arr[n]; arr[n]=sum; } } } for(int i=0; i<arraysize; i++) { smallest += arr[i]; largest += arr[arraysize - i - 1]; } printf("%d\n", largest); printf("%d", smallest); }
largest
smallest
each element = -2147483648
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)