Guest User

Untitled

a guest
Feb 22nd, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. string wyr = "drzewko";  ////string
  10. int dl = wyr.length(); //int
  11. string wyraz(dl, 'a'); //string
  12. int j = dl-1;
  13. string tab[dl]; //TABLICA STRINGÓW  // czy można dodawać do tablicy stringa zwyklego ?
  14.  
  15. cout<<"string nowy wypelniony 'a' po endlainach: "<<endl;
  16.  
  17. for(int i= 0;i<dl;i++)
  18. {
  19.     cout<<wyraz[i];
  20.     cout<<endl;
  21. }
  22.  
  23.  
  24. -------------------------------------------------------------------------------------------------------------------------
  25. -------------------------------------------------------------------------------------------------------------------------
  26. -------------------------------------------------------------------------------------------------------------------------
  27.  
  28. for(int i= 0;i<dl;i++)
  29. {
  30.     tab[i] += wyraz[i];
  31.     tab[i] += wyr[i];  
  32. }
  33.     cout<<"wyraz z -a: "<<endl;
  34.     cout<<tab<<endl<<endl;
  35.    
  36. //////////////// ---------------------> tu jest problem dodaje do tablicy dwa stringi "aaaaaa" oraz "drzewko"
  37. //////////////// ---------------------> Chce by sie zapisywalo i wypisywalo pzeplatane słowo ad az ar ae aw ak ao
  38. //////////////// ---------------------> Oczywiscie reszta sie kompiluje jak i rowniez to tylko wychodza glupoty
  39. //////////////// ---------------------> zamiast tego wychodzi: 0x28fe6c  ... to wskaźnik? Czy powiniene dodawać tablice do tablicy?
  40.  
  41.  
  42. for(int i= 0;i<dl;i++)
  43. {
  44.         wyraz[i] = wyr[i];     
  45. }
  46.     cout<<"wyraz w tej samej kolejnosci w nowym stringu: "<<endl;
  47.     cout<<wyraz<<endl;
  48.    
  49.     for(int i= 0;i<dl;i++)
  50. {
  51.    
  52.     wyraz[j] = wyr[i];
  53.     j--;
  54.    
  55. }
  56.     cout<<"wyraz w tej samej kolejnosci w nowym stringu: "<<endl;
  57.     cout<<wyraz<<endl;     
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment