Guest User

Untitled

a guest
Apr 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. // functions
  7. void populate(int*);
  8. void load(int*);
  9. void sort(int*);
  10. void output(int*);
  11.  
  12. // main
  13. int main(){
  14.     int cont = 1, array[];
  15.  
  16.     do{
  17.         cout    << "1: populate array\n"
  18.             << "2: load file into array\n"
  19.             << "3: sort array\n"
  20.             << "4: display array\n"
  21.             << "5: exit\n\n";
  22.         cin >> menu_choice;
  23.  
  24.         switch(menu_choice){
  25.             case '1': populate(array[]); break;
  26.             case '2': load(array[]); break;
  27.             case '3': sort(array[]); break;
  28.             case '4': output(array[]); break;
  29.             case '5': cont == 0; break;
  30.             default: cout << "error!\n\n"; break;
  31.         }
  32.     }while(cont == 1);
  33.     return 0;
  34. }
  35.  
  36.  
  37.  
  38.  
  39. void sort(int a[], int size){
  40.         int i, j, t;
  41.        
  42.         for(i = 0; i < size; i++){
  43.                 for(j = 0; j < i; j++){
  44.                         if(a[i] < a[j]){
  45.                                 t = a[i];
  46.                                 a[i] = a[j];
  47.                                 a[j] = t;
  48.                         }
  49.                 }
  50.         }
  51. }
Add Comment
Please, Sign In to add comment