Software Engineering 13 - University of Queensland



Software Engineering 14

Programming in C

Class Syllabus #4

Bubble Sort, String reading, ctype.h,strlen(),strcmp(), ? : operator,

the need for functions, #ifdef #endif

/*bubleSort.c*/

#include

#include

#include

#include

//#define DEBUG

#define MAX_NUMBERS 1000

#define MAX_BUFFER 256

int main()

{

double data[MAX_NUMBERS]; //this array is the actual data

int n=0; //this is the number of data elements

char inString[MAX_BUFFER]; //used to input numbers

int dotPos; //signifies the position of the dot in the number (###.####), -1 if no dot

double pow; //helps convert string to float

int i,j; //iterators

char numFlag=1; //signifies when to leave input loop

double temp; //for switch in buble sort

printf("ENTER REAL POSITIVE NUMBERS.\n"

"(TO STOP ENTERING THE NUMBERS ENTER A NON-DIGIT CHARACTER)\n");

while(numFlag && n ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download