Created
April 7, 2015 01:59
-
-
Save henrybear327/dca7d11a5d90405d277a to your computer and use it in GitHub Desktop.
w5b.c debug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
int n; | |
scanf("%d",&n); | |
while(n--) | |
{ | |
long long int x[1000]= {0},m; | |
scanf("%lld",&m); | |
long long int i,j,sum=0,temp=0; | |
for(i=0; i<m; i++) | |
scanf("%lld",&x[i]); | |
for(i=0; i<m; i++) | |
{ | |
for(j=i; j<m-1; j++) | |
{ | |
if(x[j]>x[j+1]) | |
{ | |
temp=x[j]; | |
x[j]=x[j+1]; | |
x[j+1]=temp; | |
} | |
} | |
} | |
for(i=0;i<m;i++) | |
{ | |
sum+=x[i]*(2*(m-i)-1); | |
} | |
printf("%lld\n",sum); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment