Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct elemento {
- unsigned long linha;
- unsigned long coluna;
- double valor;
- } elemento;
- elemento Representados[MAXN];
- qsort(Representados, index, sizeof(Representados[0]), lcomparator);
- int lcomparator(const void *el1, const void *el2) {
- int l1 = ((elemento *)el1)->linha;
- int l2 = ((elemento *)el2)->linha;
- int c1 = ((elemento *)el1)->coluna;
- int c2 = ((elemento *)el2)->coluna;
- if (l1 < l2) {
- return -1;
- }
- else if (l1 == l2) {
- if (c1 < c2) {
- return -1;
- }
- else if (c1 == c2) {
- return 0;
- }
- else if (c2 > c1) {
- return 1;
- }
- }
- else {
- return 1;
- }
- }
Add Comment
Please, Sign In to add comment