标签:end span namespace stream log cin bsp int iostream
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 5 int a[3010],sum[3000*1500]; 6 7 bool cmp(int a,int b) 8 { 9 return a>b; 10 } 11 int main() 12 { 13 int i,j,m,n,k; 14 while(cin>>n>>m){ 15 for(i=0;i<n;i++) 16 cin>>a[i]; 17 k=0; 18 for(i=0;i<n-1;i++) 19 for(j=i+1;j<n;j++){ 20 sum[k++]=a[i]+a[j]; 21 } 22 sort(sum,sum+k,cmp); 23 cout<<sum[0]; 24 for(i=1;i<m;i++) 25 cout<<" "<<sum[i]; 26 cout<<endl; 27 } 28 return 0; 29 }
标签:end span namespace stream log cin bsp int iostream
原文地址:http://www.cnblogs.com/ooozy/p/6260214.html