#14645: c++ sort解


100318 (曹吉百)


#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int n,i,j,t;
while(cin>>n)
{
int a[n];
for(i=0; i<n; ++i) cin>>a[i];
sort(a,a+n);
}
for(i=0; i<n; ++i) cout<<a[i]<<" ";
cout <<endl;
}
return 0;
}

#14646: Re:c++ sort解


100318 (曹吉百)


 

ㄍ更正



#include <bits/stdc++.h>

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

 

int main(int argc, char** argv) {

int n,i,j,t;

while(cin>>n)

{

int a[n];

for(i=0; i<n; ++i) cin>>a[i];

sort(a,a+n);

 

for(i=0; i<n; ++i) cout<<a[i]<<" ";

cout <<endl;

}

return 0;

}