fork download
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. void wypisz(int (*tab)[10]){
  7. for(int i=0;i<5;i++){
  8. for(int j=0;j<10;j++)
  9. cout << tab[i][j] << "\t";
  10. cout << endl;
  11. }
  12. }
  13.  
  14. int main() {
  15. srand(time(NULL));
  16. int tab[5][10];
  17. int liczba = 10;
  18.  
  19. // Wypełnianie tablicy danymi
  20. for(int i=0;i<5;i++)
  21. for(int j=0;j<10;j++)
  22. tab[i][j] = rand() % 100 + 1;
  23.  
  24. cout << "Przed posortowaniem:" << endl;
  25. wypisz(tab);
  26.  
  27. // Sortowanie
  28. int temp=0;
  29. for(int i=0;i<5;i++)
  30. for(int l=i;l<5;l++)
  31. for(int j=0;j<10;j++)
  32. for(int k=j;k<10;k++)
  33. if(tab[i][j]>tab[i][k]){
  34. temp=tab[i][j];
  35. tab[i][j]=tab[i][k];
  36. tab[i][k]=temp;
  37. j=0;
  38. }
  39. else if(tab[i][j]>tab[l][j]){
  40. temp=tab[i][j];
  41. tab[i][j]=tab[l][j];
  42. tab[l][j]=temp;
  43. i=0;
  44. }
  45.  
  46.  
  47. cout << "Posortowana tablica:" << endl;
  48. wypisz(tab);
  49.  
  50. return 0;
  51. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
Przed posortowaniem:
91	80	48	42	21	30	34	9	79	10	
38	12	7	37	95	67	72	4	39	90	
96	96	57	42	69	85	41	37	13	67	
59	3	46	6	97	67	88	30	27	66	
39	64	29	97	53	23	16	24	78	54	
Posortowana tablica:
3	4	6	9	13	16	23	24	27	54	
7	10	12	30	30	34	37	37	48	66	
21	29	38	39	41	42	46	53	67	78	
39	42	59	67	67	72	79	80	88	90	
57	64	69	85	91	95	96	96	97	97