fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. string x, y;
  9. ifstream fin_x("x.in");
  10. ifstream fin_y("y.in");
  11. ofstream fout("rezult.out");
  12.  
  13. if (!fin_x || !fin_y)
  14. cout << "Nu s-au putut deschide fisierele de intrare!" << endl;
  15. return 1;
  16.  
  17.  
  18. getline(fin_x, x);
  19. getline(fin_y, y);
  20.  
  21. cout << "x: " << x << endl;
  22. cout << "y: " << y << endl;
  23.  
  24. size_t poz = x.find(y);
  25. if (poz != string::npos)
  26. fout << "y se gaseste in x la pozitia " << poz << endl;
  27. else
  28. fout << "y nu se gaseste in x" << endl;
  29.  
  30.  
  31. fin_x.close();
  32. fin_y.close();
  33. fout.close();
  34.  
  35. return 0;
Success #stdin #stdout 0.03s 25884KB
stdin
Standard input is empty
stdout
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main() 
    string x, y;
    ifstream fin_x("x.in");
    ifstream fin_y("y.in");
    ofstream fout("rezult.out");

    if (!fin_x || !fin_y) 
        cout << "Nu s-au putut deschide fisierele de intrare!" << endl;
        return 1;
    

    getline(fin_x, x);
    getline(fin_y, y);

    cout << "x: " << x << endl;
    cout << "y: " << y << endl;

    size_t poz = x.find(y);
    if (poz != string::npos) 
        fout << "y se gaseste in x la pozitia " << poz << endl;
     else 
        fout << "y nu se gaseste in x" << endl;
    

    fin_x.close();
    fin_y.close();
    fout.close();

    return 0;