Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
怎么就是错呢???#include<stdio.h> #include<stdlib.h> int main() { long i, j, k, m, n, r, s, t, sum; int ai[100]; scanf("%d%d", &m, &n); while(m--) { for(i=0; i<n; i++) scanf("%d", &ai[i]); for(i=1; i<n; i++) for(j=0; j<n-i; j++) if( ai[j]>ai[j+1] ) { k=ai[j]; ai[j]=ai[j+1]; ai[j+1]=k; } sum=0; r=n-1; s=ai[0]; t=ai[1]; while(r>2) { if((s+t+ai[r]+t)<(ai[r]+ai[r-1]+s+s) ) sum+=(s+t+ai[r]+t); else sum+=(ai[r]+ai[r-1]+s+s); r-=2; } if(r==1) sum+=t; else if(r==0) sum+=s; else if(r==2) sum+=(t+s+ai[r]); r=sizeof(sum); printf("%d\n", r); printf("%d\n", sum); } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator