Yurttas/PL/OOL/Cplusplus/F/07/06/00/04/bubblesort 04.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 1998
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : January 1, 1998.
11   author : Salih Yurttas.
12
13   bubblesort_04.cpp
14*/
15
16
17#include <vector>
18#include <functional>
19
20#include <cctype>
21
22using namespace std;
23
24#include "bubblesort.h"
25
26int main(int argc, char* argv[]) {
27
28  vector<int> given_list;
29
30  char repeat_decision;
31
32  do {
33    get_vector_item(given_list);
34
35    char order_decision = get_char("A|D");
36
37    switch((AD)(toupper(order_decision))) {
38      case Ascending : { less<int> less;
39
40                         bubblesort(given_list,
41                                    less);
42                       }
43                       break;
44      case Descending : { greater<int> greater;
45
46                          bubblesort(given_list,
47                                     greater);
48                        }
49    }
50
51    put_vector_item(given_list);
52
53    given_list.clear();
54
55    repeat_decision = get_char("Yes/No");
56  }
57  while((YN)(toupper(repeat_decision))=='Y');
58
59}