CProgPart1EXORT2

CProgPart1EXORT2 - { int i, k, j ; int temp; for (i = 1; (i...

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 EXSORT2 /******************* Homework Assignment 1 Part 1-exsort2 By: /******************/ #include <stdio.h> #define size 10 void swap( int array1[], int i, int j); void sort( int array1[], int array1size); void disarray( 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 ; int temp; for (i = 1; (i <= array1size ) ; i++) { disparray(array1, array1size); printf("\n\n"); for (j = 0; (j < array1size - i); j++) { swap(array1, i, j ); } } } void swap( int array1, int i, int j) { int temp; if (array1[j] > array1[j+1]) { temp = array1[j + 1]; array1[j + 1] = array1[j]; array1[j] = temp; } } void disparray( int array1, int array1size) { int x; for (x = 0; x < array1size; x++) { printf("["); printf("%d", array1[x]); printf("]"); } printf(" "); //spaces between elements }...
View Full Document

This note was uploaded on 03/30/2008 for the course CS 212 taught by Professor Dr.frey during the Spring '06 term at New Haven.

Page1 / 2

CProgPart1EXORT2 - { int i, k, j ; int temp; for (i = 1; (i...

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