Cod sursa(job #2979091)

Utilizator bogdan_raul55Bogdan Raul bogdan_raul55 Data 14 februarie 2023 19:30:02
Problema Potrivirea sirurilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.81 kb
#include <fstream>
#include <string.h>
using namespace std;

ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
char z[16];
int x,y;
void printz(){
    for(int i = 0; i <= x-1; i++){
        fout << z[i];
    }
}
int main()
{
    string a,b;
    fin >> a >> b;
    x = a.length();
    y = b.length();
    for(int i = 0; i <= y-x; i++){
        bool ok = true;
        for(int j = 0; j <= x-1; j++){
            z[j] = b[i+j];
            if(z[j] != a[j]){
                ok = false;
                // fout << z[j] << " " << a[j];
                // fout << "\n";
                // fout << i+j;
                // fout << "\n";
                // fout << "\n";
                break;
            }
        }
        if(ok){
            fout << i << " " << i+x-1;    
            return 0;
        }
    }
    return 0;
}