Sorting 2D Array (21-Nov @ 04:37)
Syntax Highlighted Code
- #include <algorithm>
- using namespace std;
- [7 more lines...]
Plain Code
#include <algorithm>
using namespace std;
int X[3][3] = { {9, 8, 7}, {6, 5, 4}, {3,2,1} };
int main(){
sort(X[0], X[0]+9);
return 0;
}
Sorting records with index (21-Nov @ 04:35)
Syntax Highlighted Code
- #include <algorithm>
- using namespace std;
- [19 more lines...]
Plain Code
#include <algorithm>
using namespace std;
struct people {
int age;
char *name;
people(int a, char *n):age(a), name(n){
}
};
bool operator<(const people a, const people b){
return a.age < b.age;
}
people P[5] = { people(30, "John"),
people(20, "Jane"),
people(50, "Old man"),
people(10, "Little Boy"),
people(1433221, "Makimonster") };
int main(){
sort(P, P+5);
return 0;
}