Yurttas/PL/OOL/Cplusplus/cpp/07/06/00/05/bubblesort 05.cpp

Revision as of 19:49, 6 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="cpp" line start="1" enclose="div">/* Copyright(C) 1998 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. Perm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 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_05.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  char repeat_decision;
29
30  do {
31    char type_decision = get_char("I|F");
32
33    switch((IF)(toupper(type_decision))) {
34      case Integer : {
35        vector<int> given_list;
36        get_vector_item(given_list);
37        char order_decision = get_char("A|D");
38        switch((AD)(toupper(order_decision))) {
39          case Ascending : { less<int> less;
40                             bubblesort(given_list,
41                                        less);
42                           }
43                           break;
44          case Descending : { greater<int> greater;
45                              bubblesort(given_list,
46                                         greater);
47                            }
48        }
49        put_vector_item(given_list);
50        given_list.clear();
51      }
52      break;
53
54      case Float : {
55        vector<float> given_list;
56        get_vector_item(given_list);
57        char order_decision = get_char("A|D");
58        switch((AD)(toupper(order_decision))) {
59          case Ascending : { less<float> less;
60                             bubblesort(given_list,
61                                        less);
62                           }
63                           break;
64          case Descending : { greater<float> greater;
65                              bubblesort(given_list,
66                                         greater);
67                            }
68        }
69        put_vector_item(given_list);
70        given_list.clear();
71      }
72    }
73
74    repeat_decision = get_char("Yes/No");
75  }
76  while((YN)(toupper(repeat_decision))=='Y');
77
78}