|
|
back to boardTLE #12, How to make my code sound?? #include <iostream> int main() { int data[150000][2],i,j,n,step,temp;
std::cin >> n; std::cin.ignore(255, '\n'); for(i=0;i<n;++i) {
for (j = 0; j < 2; ++j)
std::cin>> data[i][j]; std::cin.ignore(255, '\n'); } j = 1; bool is_sorted; for(step=0;step<n-1;++step){ is_sorted = true; for(i=0;i<n-step-1;++i) {
if(data[i][j]<data[i+1][j]) { temp=data[i][j]; data[i][j]=data[i+1][j]; data[i+1][j]=temp;
temp = data[i][0]; data[i][0]=data[i+1][0]; data[i+1][0] = temp;
is_sorted = false; }
} if(is_sorted) break; } for(i=0;i<n;++i){ for (j =0 ; j < 2; ++j){ std::cout<<data[i][j]<<' '; } std::cout<<'\n'; }
return 0; } |
|
|