Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include "wortspiegel.h"
  4.  
  5. using namespace std;
  6.  
  7. string getText()
  8. {
  9. string text;
  10. getline(cin, text);
  11. return text;
  12. }
  13.  
  14. int findLastNonLetter()
  15. {
  16. return 0;
  17. }
  18.  
  19. int findNextNonLetter(string text)
  20. {
  21. return 0;
  22. }
  23.  
  24. void wortspiegel(string &text, int pos)
  25. {
  26. string tmp_text;
  27. int start = 0, end = 0;
  28. tmp_text = text;
  29. for (int i = pos; i < text.length(); i++)
  30. {
  31. if (!(text[i] >= 'a' && text[i] <= 'z') && !(text[i] >= 'A' && text[i] <= 'Z')) {
  32. end = i - 1;
  33. break;
  34. }
  35. }
  36. for (int i = pos; i < text.length(); i--)
  37. {
  38. if (!(text[i] >= 'a' && text[i] <= 'z') && !(text[i] >= 'A' && text[i] <= 'Z')) {
  39. start = i + 1;
  40. break;
  41. }
  42. }
  43.  
  44. for (int i = start; i <= end; i++)
  45. {
  46. cout << "i: " << i << endl << "das andere:" << end - (i - start) << endl;
  47. //text[i] = text[end - (i - start)];
  48. }
  49. }
  50.  
  51. int wortspiegelMain()
  52. {
  53. int cursor = 0;
  54. string text = "Dies ist ein Satz. Und noch ein Satz.";
  55. string cursorLeiste = "";
  56. char command = 'b';
  57.  
  58.  
  59.  
  60. cout << "Bitte geben Sie den Text ein: ? \n";
  61. //text = getText();
  62.  
  63. do
  64. {
  65. cursorLeiste = "";
  66. cout <<text << endl;
  67. for (int i = 0; i <= text.length(); i++)
  68. {
  69. if (i == cursor) cursorLeiste += "*";
  70. else cursorLeiste += " ";
  71. }
  72. cout << cursorLeiste << endl;
  73. cout << "Befehl (l: links, r: rechts, s: spiegeln, q: Ende) ?";
  74. cin >> command;
  75. if (command == 'l' && cursor > 0) cursor -= 1;
  76. if (command == 'r' && cursor < text.length() - 1) cursor += 1;
  77. if (command == 's') wortspiegel(text, cursor);
  78. } while (command != 'q');
  79.  
  80.  
  81.  
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement