#include <iostream>
using namespace std;
int main ( ) {
char heroes[ 11 ] [ 17 ] = { "Captain America" , "Thor" , "Wolverine" , "Cyclops" , "Goliath" , "Beast" , "Angel" , "Colossus" , "Hulk" , "Quicksilver" , "Ironman" } ;
cout << "Printing the array as is" << endl<< endl;
for ( int i= 0 ; i< 12 ; i++ ) {
cout << heroes[ i] << endl;
}
cout << endl<< "Ordering the heroes in Alphabetical order" << endl<< endl;
char temp = NULL ;
// bubble sort
for ( int i= 0 ; i< 11 ; i++ ) {
for ( int j= 0 ; j< ( 11 - 1 ) ; j++ ) {
if ( heroes[ i] [ 0 ] < heroes[ j] [ 0 ] ) {
for ( int k= 0 ; k< 17 - 1 ; k++ ) {
swap( heroes[ i] [ k] , heroes[ j] [ k] ) ;
}
}
}
}
cout << "Printing the array Sorted" << endl<< endl;
for ( int i= 0 ; i< 12 ; i++ ) {
cout << heroes[ i] << endl;
}
// Pause
cout << endl<< endl<< endl<< "Please Close Console Window" << endl;
cin .ignore ( '\n ' , 1024 ) ;
return ( 0 ) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluICgpewoKCWNoYXIgaGVyb2VzWzExXVsxN10gPSB7ICJDYXB0YWluIEFtZXJpY2EiLCAiVGhvciIsICJXb2x2ZXJpbmUiLCAiQ3ljbG9wcyIsICJHb2xpYXRoIiwgIkJlYXN0IiwgIkFuZ2VsIiwgIkNvbG9zc3VzIiwgIkh1bGsiLCAiUXVpY2tzaWx2ZXIiLCAiSXJvbm1hbiJ9OwoKCWNvdXQ8PCJQcmludGluZyB0aGUgYXJyYXkgYXMgaXMiPDxlbmRsPDxlbmRsOwoKCWZvciAoaW50IGk9MDsgaTwxMjsgaSsrKXsKCQljb3V0PDxoZXJvZXNbaV08PGVuZGw7Cgl9CgoJY291dDw8ZW5kbDw8Ik9yZGVyaW5nIHRoZSBoZXJvZXMgaW4gQWxwaGFiZXRpY2FsIG9yZGVyIjw8Z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