Cod sursa(job #2855380)

Utilizator CrisanelCrisan Alexandru Crisanel Data 22 februarie 2022 13:23:37
Problema Abc2 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

ifstream in ("abc2.in");
ofstream out ("abc2.out");

char dex[2000];

char cuv[200];

int cnd = 0;

void t (char dex2[], char cuv[])
{
    if (strstr(dex2, cuv))
    {
        //cout << dex2 << " " << cuv << "\n";
        cnd ++;
        //cout << "cuv :" << cuv << "   --- " << strstr(dex2, cuv) + strlen(cuv)<<'\n';
        t(strstr(dex2, cuv) +1, cuv);
    }
}

int nr_t = 0;

char dix[2000][100];

bool unic (char cc[])
{
    for(int i = 0; i < nr_t; i ++)
    {
        if (!strcmp(dix[i], cc))
            return false;
    }
    return true;
}

int main()
{
    char dex2[2000];

    in.getline(dex, 1999);


    while(in >> cuv)
    {

        if (unic(cuv))
        {
            strcpy(dix[nr_t],cuv);
            nr_t++;

            strcpy(dex2, dex);
            t(dex2, cuv);
        }

    }
    out << cnd;

    return 0;
}