Advertisement
desislava_topuzakova

05. Character Sequence

Jan 29th, 2023
110
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 1 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8. string text;
  9.  
  10. //текст с интервали -> getline
  11. //текст без интервали -> cin
  12. getline(cin, text);
  13.  
  14. //"Desislava"
  15. //позициите на символите са от първата (0) до последната (lenght - 1)
  16.  
  17. //начало: първата позиция -> 0
  18. //край: последната позиция -> дължина - 1
  19. //промяна: +1
  20. //повтаряме: отпечатваме символа на текущата позиция
  21.  
  22. for (int position = 0; position < text.length(); position++)
  23. {
  24. cout << text[position] << endl;
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement