Advertisement
PatrickSwayze

zad 3 roz 11

Jan 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4. string tekst1,tekst2,tekst3;
  5. int miejsce,ilosc_znakow;
  6.  
  7. namespace operacje
  8. {
  9.     string polacz(string tekst1,string tekst2)
  10.     {
  11.     return (tekst1+tekst2);
  12.     }
  13.     string usun(string tekst1,int miejsce,int ilosc_znakow)
  14.     {
  15.         return ( tekst1.erase(miejsce,ilosc_znakow));
  16.     }
  17.     bool porownaj(string tekst1,string tekst2)
  18.     {
  19.     if(tekst1==tekst2)
  20.         return 1;
  21.     else return 0;
  22.     }
  23. }
  24. using namespace operacje;
  25. void pobierz()
  26. {
  27.   cout<<"Podaj dwa ciagi znakow do polaczenia"<<endl;
  28.   cin>>tekst1;
  29.   cin>>tekst2;
  30. }
  31. void pobierz1()
  32. {
  33.     cout<<endl<<"Podaj slowo do usuniecia fragmentu ";
  34.     cin>>tekst3;
  35.     cout<<"Podaj miejsce do wyciecia ";
  36.     cin>>miejsce;
  37.     cout<<"Oraz ilosc znakow ";
  38.     cin>>ilosc_znakow;
  39.     cout<<endl;
  40. }
  41.  
  42. int main()/////////////////////////////////////////////////
  43. {
  44.     pobierz();
  45.     cout<<endl<<"1) Polaczone ciagi znakow: ";
  46.     cout<<polacz(tekst1,tekst2)<<endl;
  47.     pobierz1();
  48.     cout<<"2) Wyraz po usunieciu: ";
  49.     cout<<usun(tekst3,miejsce,ilosc_znakow)<<endl;
  50.     cout<<"3) Czy wyraz z punktu 1 sa takie same? ";
  51.     cout<<porownaj(tekst1,tekst2)<<endl;
  52.     cout<<"Koniec pracy programu"<<endl;
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement