Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cout;
- using std::endl;
- #include <iomanip>
- using std::string;
- int main() {
- short i = 0;
- short j = 0;
- short ip = 0;
- bool trovato = false;
- short count = 0;
- string m[3][3] = { {"ciao","cane","lupo"}, {"oaic","informatica","gatto"}, {"maschera","delfino","sport"} };
- while ( !trovato && j < 2 && i < 2 )
- {
- while ( m[i][j].length() == m[i + 1][j].length() && i < 2)
- {
- short l = m[i + 1][j].length();
- short ij = l;
- for ( ; m[i][j].substr(ip,ip) == m[i + 1][j].substr(ij - 1,ij - 1); count++)
- {
- ip++;
- ij--;
- }
- if ( count - 1 == l )
- {
- cout << "Trovato" << endl;
- trovato = true;
- return trovato;
- }
- else
- i++;
- ip = 0;
- ij = l;
- }
- i = 0;
- j++;
- }
- cout << "Non trovato" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement