CProgPart1EXORT3

CProgPart1EXORT3 - { int i, k, j, flag = 1 ; int temp; for...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
C Language Programming Part 1 EXSORT3 /******************* Homework Assignment 1 Part 1-exsort3 By: /******************/ #include <stdio.h> #define size 10 void swap( int array1[], int j); void sort( int array1[], int array1size); void disparray( int array1[], int array1size); int main() { int array1[size] = {4,10,5,1,6,7,3,9,8,2}; int array1size = size; printf("The original unsorted array:\n\n"); disparray(array1, array1size); printf("\n\n\n"); sort(array1, array1size); printf("The sorted array:\n\n"); disparray(array1, array1size); printf("\n\n"); system ("PAUSE"); return 0; } void sort( int array1[], int array1size)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { int i, k, j, flag = 1 ; int temp; for (i = 1; (i &lt;= array1size &amp;&amp; flag) ; i++) { disparray(array1, array1size); printf(&quot;\n\n&quot;); flag = 0; for (j = 0; j &lt;(array1size - i); j++) { swap( int array1, int j); } } } void disparray( int array1, int array1size) { int x; for (x = 0; x &lt; array1size; x++) { printf(&quot;[&quot;); printf(&quot;%d&quot;, array1[x]); printf(&quot;]&quot;); } } void swap( int array1, int j) { int flag =1, temp; if (array1[j] &gt; array1[j+1]) { temp = array1[j + 1]; array1[j + 1] = array1[j]; array1[j] = temp; } }...
View Full Document

Page1 / 2

CProgPart1EXORT3 - { int i, k, j, flag = 1 ; int temp; for...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online