/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
void
sortowanie_babelkowe (int *tab, int n)
{
for (int i = 1; i < n; i++)
{
for (int j = n - 1; j >= 1; j--)
{
if (tab[j] < tab[j - 1])
{
int bufor;
bufor = tab[j - 1];
tab[j - 1] = tab[j];
tab[j] = bufor;
}
}
}
}
void
wypisz_tablice (int tab[], int ile)
{
for (int indeks = 0; indeks <= ile; indeks++)
{
cout << tab[indeks] << " ";
}
}
int
main ()
{
string tekst;
cout << endl;
cout <<
"Wprowadź dowolną ilość liter małych i dużch, znaków specjalnych, liczb."
<< endl;
// symulujemy wprowadzenie znakC3w
tekst = "fgH9=k0G-m";
// getline (cin, tekst);
cout << "Wprowadzone znaki: " << tekst << endl;
int tekst_size = tekst.length () - 1;
char *tznak = new char[tekst_size];
int *tascii = new int[tekst_size];
for (int index = 0; index <= tekst_size; index++)
{
tznak[index] = tekst[index];
tascii[index] = tznak[index];
}
cout << "Wprowadzone znaki w kodzie ascii: ";
wypisz_tablice (tascii, tekst_size);
cout << "" << endl;
sortowanie_babelkowe (tascii, tekst_size);
cout << "Wprowadzone znaki w kodzie ascii posortowane: ";
wypisz_tablice (tascii, tekst_size);
cout << "" << endl;
return 0;
}