Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- using namespace std;
- void fun1();
- void znajdz( char element, string tresc);
- main()
- {
- int a,b;
- cout << "Pracownik" << endl;
- cout << "Klient" << endl;
- cin >> a;
- if(a==1)
- {
- cout << "1. Wprowadz kasiazke" << endl;
- cout << "2. Usun ksiazke" << endl;
- cout << "3. Wyszukaj" << endl;
- cin >> b;
- if(b==1)
- {
- fun1();
- }
- }
- }
- void fun1()
- {
- glowny = glowny + "<k>";
- string tytul;
- string autor;
- cin >> tytul;
- cin >> autor;
- glowny = glowny + "<t>" + tytul + "<t>";
- glowny = glowny + "<a>" + autor + "<a>";
- glowny = glowny + "<k>";
- }
- void znajdz( char element, string tresc)
- {
- string szukany = "";
- switch( element )
- {
- case 't':
- szukany = szukany + "<t>" + tytul + "<t>";
- break;
- case 'a':
- szukany = szukany + "<a>" + autor + "<a>";
- break;
- }
- int znaleziony = glowny.find( szukany );
- string przed = glowny.substr( 0,( znaleziony - 1 ) );
- int poczatekPozycji = przed.rfind( "<k>" );
- string po = glowny.substr(( znaleziony - 1 ),( glowny.length() - 1 ) );
- int koniecPozycji = znaleziony + po.find( "<k>" );
- string pozycja = glowny.substr( poczatekPozycji,( koniecPozycji - poczatekPozycji ) );
- int koniecTytulu = pozycja.find_last_of( 't' );
- cout << pozycja.substr( 6,( koniecTytulu - 2 ) ) << endl;
- cout << pozycja.substr(( koniecTytulu + 2 ),( pozycja.length() - 6 ) );
- }
Add Comment
Please, Sign In to add comment