0 like 0 dislike
6.4k views

Please write a program that receives 5 numbers in an array, then makes those numbers in ascending order by using bubble-sort.

**Use the template given below**

Code (Template)

#include <stdio.h>

int main(){
	int number[5]; // Do not change
	int size = 5, temporary; // Do not change
	
	for(int i=0;i<size;i++){ // Do not change
		scanf("%d",&number[i]); // Do not change
	} // Do not change

	// Your conditions start from here

	return 0;
}

 

Input 1

77 22 88 11 22

Output 1

11 22 22 77 88

 

Input 2

34 32 12 64 2

Output 2

2 12 32 34 64
[Exercise] Coding (C) - asked in Chapter 4: Arrays by (5.9k points)
ID: 37580 - Available when: Unlimited - Due to: Unlimited
| 6.4k views

46 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
* **** ** *** * ** x[] = {77,22,88,11,22};
* * * * *** * * size = 5;
    
** * *** * * ** ** print the array */
** ** ** * ** ** * * i = 0; i < size; i++){
* ** * * **** * * *** * * ** * * *** ** **** * * * ", x[i]); ** * * * * * ** * *
* * ** * *** ***
* * * ** * **** ** * * *** ** **
*** ****** ** * ******
* * * ** ** * *** ** I need this to happen size-times */
** * * * * * * ** ** * j = 0; j < size; j++){
* * ** ** * ** * * ** ** * * * * ** **** ** ** from left to right */
*** * * * *** * * ** *** ** ** * ** * ** * * i = 0; i < size-1; i++){
**** * * ****** * ** ** * *** ** *** * * *** **** i-th element with its neighbor to check if they are in order */
** * * ***** * ***** * ** * ** * * *** * ** * * ** *** * > x[i+1]){
* * ***** *** ** * * ** * * *** ** *** ** **** ***** * ** * * ** **** * ** * *** * *** exchange the values of x[i] and x[i+1] */
* * ****** * * * * * * * * ** * * * * *** * * * ***** ** **** ** ***** * temporary; *** **** ********* * * * * * *
* **** * * *** * * ****** ** * ** ***** * * * *** **** * **** **** * * **** ** * ** ** = x[i];
**** * ** ** * ** * ** * * **** * *** * * ***** ** * * ** * *** * * * * *** *** ** * = x[i+1];
* * * *** *** ** * ***** * ***** ** * *** ** * * * ** ** ****** * * *** * ***** * * = temporary;
*** * ** ****** *** * * ** ** *** **** *** * * * ** ** * * ** ** ** *** ** ** ***
* * * * ** * * * * ** *** * * *
* *** * * * * * ****
** ** *** * *** * * **
* * * ** *** ** ** * * * print the array */
** * * * * ** *** **** ** * * ***** * *** sorting: \n");
*** ***** ** ***** ** i = 0; i < size; i++){
* * * ***** *** * ** *** * *** *** * * ** * ** ", x[i]); *** ** * * * *** ******** ** ** ***
*** *** ** * ** **
*** * * * * * ** * *** *** *** * ***
** ** ** * ***** ** **
* ** * ******** * ** * ****
*** * ** *** *** ** *** * ** * ***** * ** ***
*** * ** ******* * * ** * ** *** * ** * *  
* *** * * * **** *** **** ** 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
* ** ** * ** * x[] = {77,22,88,11,22};
****** * * * * * * size = 5;
    
* ** * *** ** * * * ** ** print the array */
** * * ********* * *** i = 0; i < size; i++){
*** * ****** * * *** ***** ** * ** * *** ** * ", x[i]); *** * * ******* * * * **
* * * * * * ***
***** *** * * * *** **** * ** ** **
* ** ** **** *** * *
* ****** ** ** * **** * *** I need this to happen size-times */
* *** **** *** * * * * j = 0; j < size; j++){
* * * * *** * **** * *** * * * * *** ** * * **** from left to right */
* ** **** **** ** * * ** ******* * * ** * ** **** i = 0; i < size-1; i++){
* * * ***** ** ***** ** **** ** *** * ** * * * * * ** ** ** * * ** * i-th element with its neighbor to check if they are in order */
*** ** ***** *** * * ******* * ** ** * *** * *** **** *** ** ** * * > x[i+1]){
* ** ** ** *** *** * * * * * ** ** ** * ** *** * * *** *** * * * ** ********* * exchange the values of x[i] and x[i+1] */
* ** * * ** * * **** * * * ** ***** * ** * * * *** * ****** ** * * * *** temporary; ** * * * *** * ** * **** * *
* ** * ** * * * * * * * * * * * *** ** * *** * * *** * ** ** **** ****** * * = x[i];
* ** ** **** ****** ** ** ** *** * * ** * * * *** **** ** * * * ** ** *** *** * * = x[i+1];
******** *** ******* * * *** *** * ** * ** * * * * *** *** * ** *** * ** ** * * * * * ** = temporary;
* * ** **** * * * * * *** * ** * **** * * ***** **
*** ** ** *** * * * * * * **** ** * ** ** *
**** *** * ** * ***** **
* * ***** * *
* * *** ** * * ** print the array */
* * ** ***** ** * **** *** * * * sorting: \n");
*** ** ** * ** **** *** * i = 0; i < size; i++){
* * * *** ** *** ** * ** ****** ** *** ** *** * ", x[i]); ** * *** ** * ** * ** *
* ** ** * * ** * * *
* ** ** *** * ******* * * * ** * *
* *** * * * * * * *
** *** ** *** * *
* * ** ***** * * ** ** * * *** * **
* * * *** * * * * ** ** ** * **** *** * *  
* * ** * * *** * **** ** 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
** * ** ** ** * * * x[] = {77,22,88,11,22};
* ** * * * ** * * ****** ** size = 5;
    
* **** ** ** ***** ** print the array */
* ** * **** * * ** * i = 0; i < size; i++){
*** * * * *** ***** * * ****** * * ** * ** ** ** ", x[i]); ** * ** ****** * *** ** * **** ** ** **
** *** ***** **** ** ***
*** ** ** * * * *** ** **** * ***** * ****
* * * ** * ** *
**** * **** * *** *** I need this to happen size-times */
* * * ** * ** * * * * * j = 0; j < size; j++){
* ***** * * ** ** ** *** ** ** * * ** ********* from left to right */
*** ******* * * ** * ** ** ** * * ***** i = 0; i < size-1; i++){
**** **** ** * * *** **** * **** * * * * * ** * * * *** * * ** i-th element with its neighbor to check if they are in order */
** * ***** ** *** *** ** * *** ** ** * ** * ** ** * ** * *** * * ** ** ** * > x[i+1]){
* * ****** * ** ** * * * **** ** **** * * ** * * ** *** * * * ** * **** ** exchange the values of x[i] and x[i+1] */
* *** ** * * **** *** * ** ** * ** ** * * * * * **** ** *** ** * *** * * *** * * *** temporary; * * ** * * * * ** * * * * * ***
* * * * ** * *** * ** ** ** *** ** **** ** * * *** * * * ***** * *** *** * * * *** ** *** * * **** * * = x[i];
*** ***** **** ** * *** * * * ** ***** * ** ***** ** * *** * * *** * * *** ** * ** * ** * = x[i+1];
* *** * ******** * ****** **** *** * *** **** ** * *** * * * * ***** ******* ** * * * * **** = temporary;
*** ** * * * ** ***** **** *** *** *** *** ** ** ** ** ****
* *** *** * * * * * ** *** *
* * * *** * * ** *
* ***** * ** * *
* ** *** * * ****** ** print the array */
* ******* *** ******* * * *** *** sorting: \n");
*** ** **** ** ** ** ** i = 0; i < size; i++){
* * * ** * * ** ** * **** * * ** * * ** ** ***** ", x[i]); ** * **** * * ** *** ******* * ** *
* * ** ******** * *
*** * **** ** **** * ** * * * * *** *
* * * ********* ** *
** *** **** * **
* * * * ** * ** *** * * * * * **
* *** ** ** ***** ** **** ** * ** * ** *  
* * * * ** ** * ***** * 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
* ** *** * * ******* * * * x[] = {77,22,88,11,22};
* * * ** * * * size = 5;
    
** ***** * * * ** *** * *** print the array */
***** * ** *** ** ** * i = 0; i < size; i++){
* *** * ** ** * * * **** * ** * * ** ** * * * * ** * * ** ", x[i]); *** * * * * * * *** ** **
** ** * * *** *********** *** *
** * * * * * * * * * ** **
** ** * * ** ******
* ** ***** ***** * ******* I need this to happen size-times */
**** *** ** ** ** ** * j = 0; j < size; j++){
** *** * * **** *** *** * *** * ** *** * * ** from left to right */
* ***** *** ** *** ** * * ** * * * *** * ** * *** i = 0; i < size-1; i++){
* * * * *** ** * *** ** ** ** * * **** * * ** *** *** **** * * *** i-th element with its neighbor to check if they are in order */
* * *** * **** *** *** ** ** *** ** **** * *** *** *** * *** * ** * > x[i+1]){
* * *** *** * * * * *** ** * **** * * * * *** * ** ****** * ** ** * ** **** * exchange the values of x[i] and x[i+1] */
* * * * *** ** ** **** * ** ** *** * * * * * ** * **** ***** * * * ****** ** * temporary; * * *** ***** *** * *
* * * *** * ** * ** ** ** ** ** * *** * ** * * * * *** **** * * ** ** * ** ***** *** ** ** * = x[i];
** ** ** *** * * * ** ** *** * * * ** *** * * * * *********** ** * * **** ** ** * * = x[i+1];
** * ******* *** ** ** ** ** * ** * * * ** ** * ** * *** * **** ** ** *** ** * * = temporary;
******* ***** * **** * ***** * ** * **** * * * ***** * * ** **** * *
* ** ** * * * ** * *** **** ****** ****
*** **** ** * * *** ***
******* *** ********* * * *
* * * * * * *** **** ** print the array */
*** ** ** * * * ** ** ** sorting: \n");
* ** * ** ** ** * *** * i = 0; i < size; i++){
** ** ** * ** *** * * ** ** *** ** ** * ** * **** ** * ** ", x[i]); ** * ** * * **** ***** **
**** * *** ** ** * *
** **** **** ** * * * * * * * *** ** *
* ** ** * ***** *** *
* * * * * ** **** **
**** **** **** ** ** ** * *
* * * ** * * ***** ** ** ** * * **  
* * ** ** * *** * ** * * 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
* **** * * ** *** x[] = {77,22,88,11,22};
***** * * * * ** ** size = 5;
    
* **** ** * **** ** print the array */
**** ** ** ** **** ** i = 0; i < size; i++){
* * * ** * * ***** **** *** **** ** * * **** * ", x[i]); * *** * ** *** ** * * * ** * ****
** ** * ** * * ******* *
** * *** * *** **** ** * *** ** * ****
** ** * ** * * * * *
* * ****** * * *** ** I need this to happen size-times */
* * ** * ** * *** * * j = 0; j < size; j++){
*** *** *** ****** ***** *** **** ** * * * * *** from left to right */
** ** *** **** *** *** ** * ** * * * ** **** ** i = 0; i < size-1; i++){
* ** *** * ** * ** * * ** ***** * *** *** ** ** ********* * * i-th element with its neighbor to check if they are in order */
** * **** ** * ** ** * ** ** ***** *** * * **** * * *** *** ***** * * * * > x[i+1]){
* * * * * * ** * * * * ******* ** * ** * *** * * *** * **** * ******* ** **** * *** exchange the values of x[i] and x[i+1] */
* ** **** * ** * ** * * * * ** * **** * *** * * * *** * **** * ** ** ** * *** * temporary; *** * * * * * * * * **** *
* *** ** ** ** ******* * * **** **** * * * * * * * * * **** * ******* ** ** ** ****** ** * = x[i];
* ** ** * * * * * * * * ***** ** ** ** **** * * * * **** * * ** **** * ***** * ** ** * * * = x[i+1];
****** * * * * ****** * *** * *** *** **** ** ***** * ** * * * * * ** ** * * * = temporary;
*** *** ** ** *** *** * ** * * **** *** *** ** ** * * * **** * *** * * * *
* ********* * * * ** ** ******* *** ***
***** *** ** ** **** *
* * * ** * **** * *
* * ** * * * * * print the array */
* * * ** ***** *** * * * *** * sorting: \n");
*** * * *** * *** ** ** * * i = 0; i < size; i++){
* * ****** * **** *** * *** **** **** *** * * ", x[i]); *** **** * * * * * ** ****** ***
**** * * ** **** *
*** * * ** ** * *** * * * ********
* * * * ***** ***
* * *** * * ******* *
* * ** * ** * * * * **** **** *** * ***
* * * ****** ** *** * * * * * * * *  
**** * * * * * * 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
**** ** ****** * * * * * x[] = {77,22,88,11,22};
** ******** * *** * * * size = 5;
    
** ** ** * * ** * ****** print the array */
** ** * ** ** *** ** * i = 0; i < size; i++){
* * ** ** ** *** * * * * **** * ** ** ****** ** * ", x[i]); *** * ** * * **** ** *** * *******
**** * ******* * **** **
* * ** ** *** * * * * ** *** * *
* ** * ** * ****** * * * *
* * *** * ** ** * ** * I need this to happen size-times */
*** ** * * ** * ** *** ** *** j = 0; j < size; j++){
* * *** * ***** ** *** ********* * * ** * from left to right */
**** * * ** ***** **** * ** *** * *** * * **** i = 0; i < size-1; i++){
* ** *** * **** * *** ** ***** *** ** * * ** * * * ** * ***** i-th element with its neighbor to check if they are in order */
* * * * *** *** ** ** ** ** ***** * * ** * * * * * > x[i+1]){
* * * * * ***** ** **** * * * ******** * * * * ***** *** ** * * ** *** * exchange the values of x[i] and x[i+1] */
** ** ** *** ** * * ** * * ** *** *** **** ** ** * ** * *** * * ** **** * * **** temporary; * ** ** * * *** * * * * ****
*** * ** ** * * *** *** ****** ** ** * * * ** * * ** *** * ** * ** * * *** = x[i];
**** * * * * * ** ** *** **** ** * * * ******* * * * * ** ** * *** * * * * *** ** = x[i+1];
* * * * *** * ** * ** ***** **** * *** *** * * ** * ***** * *** *** **** * ** * *** = temporary;
*** **** * * * * * * * *** * **** * ** ** **** *** * ** * * *** ** * *
**** *** * * **** * ** * ** * * * ** * *
* *** **** ** *** ***
*** * * ** * *
* **** * * ** ** ** * *** print the array */
** *** **** ** ** *** * * * * *** * sorting: \n");
*** ** *** * * ** i = 0; i < size; i++){
* * * * **** ******** *** * * * * ** ** * ** ****** * ", x[i]); ** ** ******* * * **** * *
* * * *** * *** ** * * **
* * * * ** *** *** **** ***** * * *
* * * * ** **
*** ****** ** ** *****
* *** * ****** ** * * *** ** **
** ** ** *** * * * * * ** * * **** ** *** *** *  
* *** *** * * * * ** * 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
**** * * * ** * * x[] = {77,22,88,11,22};
* * * * **** * *** * * size = 5;
    
*** ** ** * * * * ** print the array */
** *** ** * ** ****** * i = 0; i < size; i++){
*** ** * * * ** ** * * * **** ****** ** ** ", x[i]); **** ****** * *** ** *** * * * * ***
* *** ***** * ** *
** *** **** *** * ***** *** ** **** ****
** **** ***** **** **
* * ***** * ************ I need this to happen size-times */
* * * * * * * * ** j = 0; j < size; j++){
** * * * * *** * * *** * **** * ** * * *** from left to right */
**** * *** *** * ** * *** ** ***** * * ** * ** i = 0; i < size-1; i++){
** ******* * * * * * ** ******* * * * ** ** * * * i-th element with its neighbor to check if they are in order */
* * * * * * * * ** * * ****** * ** * * ** * * * ** *** * > x[i+1]){
** * **** * **** * ** * **** * * **** * ** * * ** *** ** ** * * * * exchange the values of x[i] and x[i+1] */
* **** * * * *** ***** ** **** **** * * *** ** * ** ** ** * * ** * * *** * **** * ** * temporary; * ** * * ***** * ** ** **** * **
* ** ** ** * * ** *** * ** * ** ****** * **** ** * * ** * ** **** *** ** ** * ** ** * * * * = x[i];
* ** ** *** ** **** * ** * ** * *** * * * ** * **** ** * **** ** * * **** = x[i+1];
* ** * ***** *** * *** * ***** **** * * * * * ***** * * ** ** * *** *** * * ***** ** *** * = temporary;
** * *** * **** ** *** * * ** ** *** * * ** ** * * ** ** *** * **
* ** * *** * * *** * * * *** *** *
* ***** ** * * * * **
* * ***** ** * *
*** * ***** ** ** *** * print the array */
** ******** * ** *** *** sorting: \n");
* *** * ** * *** * i = 0; i < size; i++){
** *** * ******** * * * ******** *** *** * ** * * **** ", x[i]); ** * * ** * *** ***** ****
* *** * * *** ** * *****
** * ** ** *** * * ** * ********* *
*** * ** ****** ** *
** * * * *** * **
* **** *** * *** * * * * ** * ** * * ***
** * ** * ** * * ** * *** * * * * * * ** * *  
* *** ** * * ** *** 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
** * ** ******** x[] = {77,22,88,11,22};
********* * ** * * ** size = 5;
    
* * ** ***** **** * * * print the array */
* * * *** * * *** i = 0; i < size; i++){
* ** ** * * * * * *** * *** * * * * * ", x[i]); * ** ***** ** ****** * * * *** ** ** *
*** *** *** * * **
** ***** * * * * ** ** ** * ** * **
*** * * *** * ***
* * * ** * * * * I need this to happen size-times */
* ** **** * ** * * * * * * j = 0; j < size; j++){
* * * ** ** **** **** * * * * * * * * ** ** ** from left to right */
** * * ***** ** ** ** ****** * * *** ** * * * ** * i = 0; i < size-1; i++){
**** * * * * ** * * **** ***** * *** ** * * ** * * * * **** ***** **** * ** *** i-th element with its neighbor to check if they are in order */
* * * ** * * *** * ***** * ** * ** ** ** **** * *** *** * ** * > x[i+1]){
* * * * **** * * * * * ** **** ** * * ******* * ** *** ** * * * * * *** exchange the values of x[i] and x[i+1] */
* **** ** * * ** ** ** *** ** * ** * * * * ***** * ** * * ** ** * * * * * * ** ****** * temporary; * *** ***** ** *** ** * * * ** *** **
** ** * * *** * ** * ** ** * * * ** ***** **** *** *** * ** * ** * **** * * * ** ** **** = x[i];
* *** ** * * ** * * * ***** * ** * * * *** ** * * ** * ** ** * * * **** * *** * = x[i+1];
***** ***** *** ***** * ******* **** *** * * ** **** ** **** ** * * * ** **** ***** *** * ** * * = temporary;
* ** **** * ** * * *** * * *** ** ** * **** * * * * **
* * ** **** **** ***** ** * *** ** * * *
** * *** * ** * **
** *** * * ** ****
*** * * *** * * ** *** *** print the array */
* * * ** ** **** * ***** ** ** *** sorting: \n");
*** * * * * **** ** * * i = 0; i < size; i++){
** ***** * * * * **** * * *** * ** * * * * ", x[i]); ** * * ***** * * *** * **
* * * ** *** ***** * *
* ** *** ***** ** * * * * **** ** *****
**** ** **** ** * *
** ** *** * * * ******
** *** * **** ***** ** **** * * * * * * *
** ** ** *** * * * ** * *** * ****** ****  
** ** *** *** * **** * 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
** ** * * * ** *** x[] = {77,22,88,11,22};
** *** * * *** **** ** size = 5;
    
** ** **** *** ***** print the array */
** * ******* ** * * ** ** i = 0; i < size; i++){
** * * * *** ** ***** *** * ** * *** **** **** * ", x[i]); ** * **** * * **** ** ** * * ******
* * ******* * * ***
* * **** * * * ** *** * * * **
******* * * * * *
* ** * * ** * ** * I need this to happen size-times */
* * ** * *** **** * j = 0; j < size; j++){
* * * ** * *** * ** * *** ****** * * * * from left to right */
*** ** ** ** * * * ** *** ** * **** *** * ** i = 0; i < size-1; i++){
** **** * * * ******* * *** * *** * *** * *** ** *** * ** ** * ** * i-th element with its neighbor to check if they are in order */
*** * * **** * ******* * * ********* * * ** * * ** * ** > x[i+1]){
* * * **** * * *** *** * **** ******* ** * ** * * * * *** ** *** ** * * ** exchange the values of x[i] and x[i+1] */
* * * *** * * ***** * **** * *** ** * ** * ** ** * ** * **** ** * ** * * ***** *** **** ** temporary; ** * * * *** * ** * * * *
* * * ** * * ** ** * * * ** * ** * ** **** ** *** *** * * * ***** ** ** ** * ** * = x[i];
*** ********* * ** * * ** * * * ** * * ** ** ** * ********** * *** ***** * * ** *** * = x[i+1];
**** *** ***** * * ** ** *** *** *** * *** * ** * * * *** *** ** * ** * * * *** ** * * = temporary;
* *** ** ** ** ** *** *** * * ** ** * ** * * * ******* *** * *****
* * **** * ** ** ** * * * * ***** **
* * * * * *** ** * * **
** * ** ** ** * * * **
* *** ** ** ** ** print the array */
* ***** * ** ** ****** **** * * *** *** sorting: \n");
* * *** ** ****** ***** * **** i = 0; i < size; i++){
** ** * ** ** ********** ** ** ** * * * *** * ", x[i]); ** *** *** * ** * * ** * ****
* ** **** ****** ***
* *** **** ** * ** * ** * * * **** ** * *
** * ** * * * *** ** ****
* * * ** * ** **
* * * ***** **** ** * * *** * *
* * ****** *** * * **** * * ***** * * *  
* * * * * * ******** 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
*** ** *** ** ** * x[] = {77,22,88,11,22};
* ** ** ** *** **** size = 5;
    
* ** * * *** ** print the array */
*** * ** ****** *** ** * ****** *** i = 0; i < size; i++){
** * * ****** *** ** * *** * * * **** *** * * **** ", x[i]); ** **** * * *** **** ****** * * * *
** ** ** * **
* *** * ** ** * **** * * * * * * *
* * * * ** * *** ** * *
* * * *** * *** ** I need this to happen size-times */
**** * *** * ******* * **** *** j = 0; j < size; j++){
*** * * * ** * * * * * ** ** *** ** * ** from left to right */
* ***** ** ** * ** **** * * * * *** ** ** * * * i = 0; i < size-1; i++){
** * *** ** ** *** * * * *** ** * *** * * ** ** * *** i-th element with its neighbor to check if they are in order */
** * ***** ** * * ** * * * ** *** **** * * * * ***** **** **** * > x[i+1]){
*** *** ** * * ** * ***** * **** ** ** * *** * * * ***** ** *** ** ***** * exchange the values of x[i] and x[i+1] */
* **** * ** * ** * * * *** ** **** ** * * * ** ** **** *** * * * * * * * ** *** * * temporary; * ** ** ** ***** * * * * ** *
* * ** ** *** ** * * **** * ** **** * * * * * ** *** * * ** ** ****** ** ** * ***** *** = x[i];
* *** * ** ** * * ** * * ******* * * * *** ** * **** ** ** * ** ** * * *** * * * = x[i+1];
* * * * ***** * *** * *** ** * **** * *** ** *** **** * ** * **** * * **** = temporary;
** * ** ** * * * * ** * * *** ** * * **** ** *** * * * ****** *
* ** * **** *** ** *** ** ***** * ***** **** ******
*** ***** * **
** ** ** * * ** ** *
** * * * * *** ** * print the array */
** * * * ** * * ** **** ** * ** *** ** sorting: \n");
* ** * ***** **** ** * i = 0; i < size; i++){
** *** *** ** * * * * *** * * ** * ** * *** ", x[i]); * *** * * ** ** ****** ** ***
** ** * ** * *** *** ** *
* * ***** * ** * * *** * **** * * *
* ****** * * * *
* **** *** ***** ******* *
*** ** * * * * * * *** *
** * * ***** * * * * *** ** * ** *** * * * **  
* * * ** * * ** * *** ** * 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.58.131
©2016-2025

Related questions

0 like 0 dislike
0 answers
[Resource] asked Dec 15, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 37571 - Available when: Unlimited - Due to: Unlimited
| 6 views
0 like 0 dislike
18 answers
[Exercise] Coding (C) - asked Jan 5, 2018 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 41054 - Available when: Unlimited - Due to: Unlimited
| 4k views
0 like 0 dislike
20 answers
[Exercise] Fill in the blank - asked Dec 15, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 37578 - Available when: Unlimited - Due to: Unlimited
| 2k views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Dec 7, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 35804 - Available when: Unlimited - Due to: Unlimited
| 3.4k views
0 like 0 dislike
18 answers
[Exercise] Fill in the blank - asked Dec 7, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 35798 - Available when: Unlimited - Due to: Unlimited
| 1.7k views
12,783 questions
183,442 answers
172,219 comments
4,824 users