Witam,
#include <iostream>
#include <string>
#include <windows.h>
#include <cstdlib>
using namespace std;
void powitanie()
{
cout << "Witaj w programie CENZURA v1." << endl;
}
void autor()
{
cout << "Autor programu: Archeon " << endl;
cout << "Student II roku Informatyki " << endl;
}
void menu()
{
cout << "|_____Cenzura v1 ____|" << endl;
cout << endl;
cout << "1. Przetestuj program " << endl;
cout << "2. O programie " << endl;
cout << "3. O autorze " << endl;
cout << "4. Wyście " << endl;
cout << endl << endl;
cout << "Wybierz opcje : " << endl;
}
void program()
{
cout <<"Program ma nanosic cenzure na brzydkie wyrazy :)" << endl;
}
string cenzura(string & Tekst )
{
// ZAMIANA kurka na "*****" //
string przeklenstwo_k = "kurka";
string sWynik = Tekst;
size_t pos = 0;
while((pos = sWynik.find(przeklenstwo_k, pos)) != string::npos)
{
sWynik.replace(pos, przeklenstwo_k.size(),przeklenstwo_k.size(), '*' );
pos += przeklenstwo_k.size();
}
return sWynik;
}
int main(int argc, char** argv) {
system("chcp 1250");
system("cls");
powitanie();
Sleep(1000);
system("cls");
menu();
int wybor;
string tekst;
cin >> wybor;
switch( wybor )
{
case 1:
{
cout << "Test programu " << endl;
Sleep(1000);
system("cls");
cout << "Podaj wyraz aby zobaczyć cenzurę :";
cin.ignore();
getline(cin, tekst);
cout << cenzura( tekst ) << endl;
break;
}
case 2:
system("cls");
program();
break;
case 3:
autor();
break;
case 4:
system("cls");
cout << "Nastąpi wyjście z programu .." << endl;
system("exit");
break;
}
return 0;
}
Wymyśliłem sobie program który ma cenzurować wyraz jaki ustalę wcześniej w kodzie.
Chciałbym teraz to ulepszyć i stworzyć "bazę" takich wyrazów które będzie automatycznie cenzurował ?
Czy ktoś potrafi mi powiedzieć jak powinienem to zrobić ?
Oto mój kod :