Matura 2018 maj – Słowa
ROZWIĄZANIE ZADANIA
#include <algorithm>
#include <iostream>
#include <fstream>
using namespace std;
int main() {
//pkt.A
fstream in;
string slowo;
int wynik=0;
in.open("plik.txt", ios::in);
while(in >> slowo)
{
if (slowo[slowo.size()-1]=='A')
wynik++;
}
cout << "liczba slow = " << wynik;
in.close();
//pkt.B
string slowo2;
wynik=0;
in.open("plik.txt", ios::in);
while(in >> slowo)
{
in >> slowo2;
size_t pozycja = slowo2.find(slowo);
if (pozycja != string::npos)
wynik++;
}
cout << "\nliczba wierszy = " << wynik;
in.close();
//pkt.C
//Rozwiązanie dostępne jest w Platformie Edukacyjnej.
return 0;
}
Pages: 1 2