hi im doing a project using the bubblesort feature. I have to print out an inputted array of 26 characters sorted by ascii characters. i need to print them out ascending and descending, and also print out the top 3 occuring characters and their counts. i also need the largest and smallest character by ascii code.
#include <iostream>
using namespace std;
void input (char ulist[26], int& n);
void Bubblesort (char ulist[26], char slist[26], int n);
void print(char list[26], int n);
double average;int n,sum;
void main()
{
char ulist[26], slist[26];
input(ulist, n);
cout << "Unsorted" ;
print(ulist, n);
cout << "Sorted";
Bubblesort (ulist,slist,n);
print(slist,n);
}
void input(char ulist[26], int& n)
{
int i(0);
char value;
cout << "enter character : \n";
cin >> value ;
while (i < 26 && value != '#')
{
i++;
ulist[i] = value;
if (i<26)
{
cin >> value ;
}
}
n=i;
}
void Bubblesort(char unlist[26], char sortlist[26], int n)
{
int i,j,temp;
for (i=1;i<=n;i++)
sortlist[i] = unlist [i];
for (j=1;j<=n-1;j++)
for (i=1;i<=n-j;i++)
if (sortlist[i] > sortlist[i+1])
{
temp = sortlist[i];
sortlist[i] = sortlist[i+1];
sortlist[i+1] = temp;
}
}
void print(char list[26], int n)
{
int i;
sum = 0;
cout << " list of characters by ASCII code are : \n";
for (i=1; i<=n; ++i)
{
cout << list[i] << '\n';
sum = sum + list[i];
}
}
so far it prints out the unsorted and the sorted (ascending)
any help would be appreciated