So I've written this code which lets you decide how many rows you want with seven numbers in it. But I want them sorted and the same number can't appear again on the same row. I know about bubbleSort but I can't seem to get it work... Can someone explain step by step so I can understand? Here's the code for the rows:
Well firstly, why post in english then code in another language, makes it harder to read as variable and comments are meaningless and you did not use [code] tags.
Somethings I can see:
1. Make a new function and name it accordingly to what you want (bubble sort in this case).
2. Convert your string to a standard case (all lower case for example) then compare if it the desired word, no need for 7 comparisons in your if statement.
3. Use code tags.
Fixed the code tag. Didn't know that one because I'm new here.
Why I wrote it in another language? Because I'm from another country and I did a copy paste. Editing the variables and text takes its time. What do you mean by string?
Why not make an array and make it compare the seven numbers in the array?
you need 2 nested loops. both iterate over the size of the array. The inner loop swaps the values of the array if necessary (a[j] > a[j + 1]) and set a bool variable (is_swapped or whatever) to true. the outer loop sets is_swapped before the inner loop to false. After the inner loop is done and is_swapped remains false you may break the outer loop (the sort is done)