language: C++ 4.7.2 (gcc-4.7.2)
date: 365 days 3 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <cstring>
 
using namespace std;
 
int main (){
 
    char data[10][40] = {     
      "",
      "Welcome",
      " !\"#$%&'()*+,-./0123456789:;<=>?@",
      "aBCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`",
      "abcdefghijklmnopqrstuvwxyZ{||||||||||}",
      "CD_ROM",
      "ROM",
      "SCS",
      "3.5 Floppi",
      ""
    };
 
 
    cout<<"Printing the array as is"<<endl<<endl;
 
    for (int i=0; i<10; i++){
            cout<<data[i]<<endl;
    }
 
    cout<<endl<<"Ordering the data in Alphabetical order"<<endl<<endl;
 
 
    // bubble sort
 
    for (int i=0 ; i<10-1 ; ++i) {
            char Tcopy[40];
            for (int j=i+1 ; j<10 ; ++j) {
                    if (strcmp(data[i], data[j]) > 0) {
                            strcpy(Tcopy, data[i]);
                            strcpy(data[i], data[j]);
                            strcpy(data[j], Tcopy);
                    }
            }
    }
 
 
    cout<<"Printing the array Sorted"<<endl<<endl;
 
    for (int i=0; i<10; i++){
            cout<<data[i]<<endl;
    }
 
 
// Pause
    cout<<endl<<endl<<endl<<"Please Close Console Window"<<endl;
    cin.ignore('\n', 1024);
    return(0);
}