Witam, mógłby ktoś mi pomóc z programem sortującym pozycyjnie?
Muszę przerobić ten kod, aby duże litery traktował jak małe , ale nie wiem jak się za to zabrać.
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <conio.h>
using namespace std;
char zamien(char litera);
int main()
{
system("color 3F");
int m, n, a, k;
cout << "Podaj max. dl. ciagu znakow: ";
cin >> m;
cout << "Podaj ile wyrazow bedzie wprowadzone: ";
cin >> n;
char tab[n][m+1], temp[n][m+1];
for(int i = 0; i < n; i++)
{
cout << "Podaj " << i+1 << " wyraz: ";
cin >> tab[i];
temp[i][0] = '\0';
}
cout << "\nElementy tablicy przed sortowaniem:\n";
for(int i = 0; i < n; i++) cout << tab[i] << "\n";
a = n;
for(int k = m; k > 0; k--) //Przenoszenie elementow
{
int j = 0;
for(int i = 0; i < n; i++)
{
if (strlen(tab[i]) >= k)
{
for(int l = 0; l <= m; l++) temp[j][l] = tab[i][l];
tab[i][0] = '\0';
a--;
j++;
}
}
for(int i = 0; i < n - 1; i++) //
{
if ((strlen(tab[i]) == 0) && (a > 0))
{
bool b = false;
for(j = i + 1; (j < n) && (b == false); j++)
{
if (strlen(tab[j]) > 0)
{
for(int l = 0; l <= m; l++) tab[i][l] = tab[j][l];
tab[j][0] = '\0';
b = true;
}
}
}
}
for(char znak = 'a'; znak <= 'z'; znak++)
{
for(int i = 0; i < n; i++)
{
if ((strlen(temp[i]) > 0) && (temp[i][k - 1] == znak))
{
for(int l = 0; l <= m; l++) tab[a][l] = temp[i][l];
temp[i][0] = '\0';
a++;
}
}
}
}
cout << "\nElementy tablicy po sortowaniu:\n";
for(int i = 0; i < n; i++) cout << tab[i] << "\n";
return 0;
}