/* ************************************************************************** * Program name : 053_Function_and_pointer (Version 1.00) * * Author : Duck Wong * * Language : C / C++ * * Compiler : Boodshed Dec-C++ compiler Ver 3.95 * * Computer : PII350 * * O/S : Windows 98 * ************************************************************************** * Version 1.00 : 2000/07/01 - first version * ************************************************************************** * Description : (a) Input an integer number (0-5) * * (b) Output an error message * * (c) Output the memory address and elements of Values * * (d) Try again ? * ************************************************************************** */ #include #include void Function_Input(int [], const int); void Function_Min_and_Max(int [], const int); void Function_Bubblesort(int [], const int); int main() { // part 1 : declaration const int element = 6; int Number[element]; char Again; do { // part 2 : Use different method to call function Function_Input(Number,element); Function_Min_and_Max(Number,element); Function_Bubblesort(Number,element); // part 3 : try another number ? cout << "\n\n\tTry another number (Y/N) : "; cin >> Again; cout << "\n"; } while (Again=='Y' || Again=='y'); cout << "\n" << endl; system("PAUSE"); return 0; } void Function_Input(int Number[], const int element) // Note (1) { int Index; cout << "\nPart (1) : Call by reference with reference arguments\n"; for (Index=0; Index> Number[Index]; } cout << "\n\n\tThe numbers are : "; for (Index=0; Index Max) Max = Num[Index]; } cout << "\n\tThe minimum number in the list is : " << Min << "\n\tThe maximum number in the list is : " << Max; cout << "\n\nEnd of Function_Min_and_Max\n\n"; system("PAUSE"); } void Function_Bubblesort(int *Num, const int element) // Note (1) & (2) { void swap(int *, int *); // Note (3) int Index_1, Index_2, tempint; char swapYN; for (Index_1=1; Index_1Num[Index_2+1]) { swap(&Num[Index_2], &Num[Index_2+1]); swapYN = 'Y'; } if (swapYN=='N') break; } cout << "\nPart (3) : Call by reference with pointer argument - example 2\n"; cout << "\n\n\tAfter sorting, the numbers becomes : "; for (Index_1=0; Index_1