Cod sursa(job #2855386)

Utilizator leo05Leonardo Mosutan leo05 Data 22 februarie 2022 13:27:21
Problema Abc2 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.11 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;

int main()
{
    ifstream in("abc2.in");
    ofstream out("abc2.out");
    
    int ok = 0, n = 0, k = 0, bn = 0;
    char cuvant[1001], cuvant1[1001][1001], cuv[1001], cuvaux[1001], cuvant2[1001][1001];
    in >> cuvant;

    while(in >> cuv){
        strcpy(cuvant1[n++], cuv);
    }
    
    for(int i = 0; i < n-1; i++){
        ok = 0;
        for(int j = i+1; j < n; j++){
            if(cuvant1[i] == cuvant1[j])ok++;
        }
        if(!ok){
            strcpy(cuvant2[k++], cuvant1[i]);
        }
    }

        
    for(int i = 0; cuvant[i] != NULL; i++){
        for(int j = 0; j < k; j++)
            if(strstr(cuvant+(strlen(cuvant2[1]))+i, cuvant2[j]))bn++;
    }
    out << bn;
}