How can i print each passes? Thank you | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can i print each passes? Thank you

Heres my code https://code.sololearn.com/ceoMn4MPpGfe/?ref=app

6th Feb 2022, 3:54 AM
Juven Perante Torres
Juven Perante Torres - avatar
29 Answers
+ 1
Hii bro finally I have modified your original code and now it's working fine... This is the modified one.... https://code.sololearn.com/cU52tEFs8E3V there were some warnings and some silent errors which i had removed. Let's check it once and let me know
6th Feb 2022, 11:48 AM
saurabh
saurabh - avatar
+ 1
@Juven Perante Torres Hey, You should see this code and let me know if you are satisfied... https://code.sololearn.com/c53gSLAZF9Nm Thanks for asking..
6th Feb 2022, 7:17 AM
saurabh
saurabh - avatar
+ 1
Thanks
6th Feb 2022, 8:32 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
But i need is it can work on my code with passes/iteration can you show me?
6th Feb 2022, 8:41 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
The main victim is continue; statement in your code. Once this condition `elem<arr[i-1]` returns false ==> else statement execute and continue means skip all and again start new iteration. To resolve this you also have to print the pass/iteration inside else statment just before continue; . This is the implementation https://code.sololearn.com/cU52tEFs8E3V Thanks...
6th Feb 2022, 9:01 AM
saurabh
saurabh - avatar
+ 1
Its not working
6th Feb 2022, 9:38 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
Can you gimme the input you are trying ? because it's working on my side.
6th Feb 2022, 10:29 AM
saurabh
saurabh - avatar
+ 1
I think you have .modified and tried on your code.. If this is case.. Please check which i had posted and then let me know.
6th Feb 2022, 10:32 AM
saurabh
saurabh - avatar
+ 1
Like this [1]Ascending [2]Descensing 1 How many array [4]minimum [16] maximum 4 Enter array elements: 4 1 5 2 Pass 1 4 1 4 5 1 2 4 5 Sorted array 1 2 4 5
6th Feb 2022, 10:32 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
I am not understanding in which form the pass you want ? Do you want array in each pass or only sorted part ? My code gives array after each pass.....
6th Feb 2022, 10:37 AM
saurabh
saurabh - avatar
+ 1
I want my code when running ia look like that
6th Feb 2022, 10:39 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
Your is not working it show errors in printing passes but it ia not in logical error
6th Feb 2022, 10:40 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
Can u please paste the code here that you are running .
6th Feb 2022, 10:42 AM
saurabh
saurabh - avatar
+ 1
The one that you sent i use codeblocks ide
6th Feb 2022, 10:43 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
Bro, because of the issue, i installed code blocks ide on my pc and run the code I had posted and I got the following results .......... ### test case 1 ###### Enter the Size for Array: 4 Enter 4 Array Elements: 4 1 5 2 Step 1: 1 4 5 2 Step 2: 1 4 5 2 Step 3: 1 2 4 5 The New Array (Sorted Array): 1 2 4 5 #### test case 2 ###### Enter the Size for Array: 5 Enter 5 Array Elements: 10 20 30 40 50 Step 1: 10 20 30 40 50 Step 2: 10 20 30 40 50 Step 3: 10 20 30 40 50 Step 4: 10 20 30 40 50 The New Array (Sorted Array): 10 20 30 40 50 #### test case 3 ###### Enter the Size for Array: 5 Enter 5 Array Elements: 50 40 30 20 10 Step 1: 40 50 30 20 10 Step 2: 30 40 50 20 10 Step 3: 20 30 40 50 10 Step 4: 10 20 30 40 50 The New Array (Sorted Array): 10 20 30 40 50 ------------------------- I haven't got any syntax error..... i am not getting what is problem with your ide...
6th Feb 2022, 10:56 AM
saurabh
saurabh - avatar
+ 1
Im so sorry i sent the wrong codes. Here mine that i want to have a passes https://code.sololearn.com/c1McjP4gY2I2/?ref=app
6th Feb 2022, 11:06 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
Please help mo bro im so sorry
6th Feb 2022, 11:15 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
Thank you bro. Godbless you and your family
6th Feb 2022, 11:49 AM
Juven Perante Torres
Juven Perante Torres - avatar
+ 1
You are welcome bro, please mark it as the best answer if it really helped you.
6th Feb 2022, 11:54 AM
saurabh
saurabh - avatar
+ 1
How can i mark it?
6th Feb 2022, 12:00 PM
Juven Perante Torres
Juven Perante Torres - avatar