c++ - How to counting sort two dimensional array -


hi have problem code, try sort array counting sort (it must stable sort), code doesn't work. try implemented counting-sort wbesite, in c# , i'm not sure s done correctly. can tell me wrong it?

#include <stdio.h> #include <iostream>  using namespace std;   void sort_with_show(int **a, int rozmiar, int polecenie) {     int y, d;     (int = 0; i< rozmiar - 1; i++)     {         (int j = 0; j < rozmiar - 1 - i; j++)         {             if (a[j + 1][0] < a[j][0])             {                 y = a[j][0];                 a[j][0] = a[j + 1][0];                 a[j + 1][0] = y;             }         }     }      (int = 0; < rozmiar; i++)     {     //cout << tablica[i].x << " " << tablica[i].y << "\n";         if (polecenie == 0)         {             cout << a[i][0] << '\n';         }         else if (polecenie == 1)         {             cout << a[i][0] << "," << a[i][1] << "\n";         }     } }  int main() {       int rozmiar = 0;     int polecenie = 0;      char t[20] = { '\0' };     char *p, *q;      int liczba = 0;     int calaliczba = 0;      bool isy = false;     cin >> rozmiar;      int **  = new int *[rozmiar];     (int = 0; < rozmiar; i++)         a[i] = new int[2];      cin.ignore();      int = 0;     while(i < rozmiar)     {         fgets(t, sizeof t, stdin);          (p = t, q = t + sizeof t; p < q; p++)         {              if (*p >= 48 && *p <= 57)             {                 liczba = *p - 48;                 calaliczba = calaliczba * 10 + liczba;             }              if (*p == ' ')             {                 a[i][0] = calaliczba;                 isy = true;                 calaliczba = 0;                 liczba = 0;             }              if (*p == '\n')             {                 a[i][1] = calaliczba;                 isy = false;             }          }          (int j = 0; j < 20; j++)             t[j] = '\0';          liczba = 0;         calaliczba = 0;         isy = false;         i++;     }      cin >> polecenie;     cin.ignore();      sort_with_show(a, rozmiar, polecenie);     return 0; } 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -