Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- # include <cstdlib> //Prototyp f. toupper()
- using namespace std;
- class Licznik
- {
- public: // wszystko będzie dostępne "na zewnątrz" klasy
- char znak;
- int ile;
- void Inicjuj(char x)
- {
- znak = x;
- ile = 0;
- }
- void PlusJeden(void)
- {
- ile++;
- }
- };
- int main(int argc, char *argv[])
- {
- char znak_we;
- Licznik licznik; // tworzę obiekt o nazwie "licznik" który jest typu "Licznik"
- licznik.Inicjuj('A');
- cout << "\nWpisz tekst zawierajacy litery A";
- cout << "\nPierwsze wytapienie litery k lub K";
- cout << "\n - oznacza Koniec zliczania: ";
- for(;;)
- {
- cin >> znak_we;
- if (znak_we == 'k' || znak_we == 'K') break;
- if(licznik.znak == toupper(znak_we)) licznik.PlusJeden();
- }
- cout << "\nLitera " << licznik.znak
- << " wystapila " << licznik.ile
- << " razy\n."<<endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment