c - Sort 2x3 Matrix without using qsort -


My teacher has assigned something that I can not find that qsort We have given 2x3 array, and he wants us to sort each row from minimum to maximum. I do not have permission to use qsort for learning purposes; In my opinion, it is difficult, it is difficult.

Even so far away from me; At present, the program crashes, I think this is because when it goes to the third column, there is nothing in the fourth column [j + 1] , hence it gives an error is.

  #include "stdafx.h" # Include & lt; Stdio.h & gt; Int main () {int x [2] [3] = {{2, 3, -1}, {0, -3, 5}}; // 2x3 matrix; 2 rows, 3 columnless sortmainmax (int b [] [3], int nurv, int nuclum); // function prototype sortManMax (X, 2, 3); Return 0; } For Zero Semenax (Int a [] [3], IntraNerv, Int Newcomp.) {For (Int i = 0; I  a [i] [j]) {// swap values ​​if the current number in the current number int temp = a [i] Less than [j]; A [i] [j] = a [i] [j + 1]; A [i] [j + 1] = temporary; } printf ("% i \ t", a [i] [ja]); } Printf ("\ n"); } Return; }   

I appreciate any and all help!

  1. I believe int i = 0; I & lt; = numRow; I ++ should be int i = 0; I & lt; NumRow; I ++
  2. Why do you have (i == 0) & amp; If (i == 1) if you are doing the same stuff?
  3. It seems that you tried to implement the bubble-sort-algorithm, but you only pass one data

    Examples of bubble sort algorithms For (int x = 0; x & lt; n; x ++) {for (int y = 0; y and lt; n-1; y ++) {if (Array [y]> array [y + 1]) {int temp = array [y + 1]; Array [y + 1] = array [y]; Array [y] = temporary; I can get a better option for j = n: i + 1 for swapping = j = 1: n

    One [ja]

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -