Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include "wortspiegel.h"
- using namespace std;
- string getText()
- {
- string text;
- getline(cin, text);
- return text;
- }
- int findLastNonLetter()
- {
- return 0;
- }
- int findNextNonLetter(string text)
- {
- return 0;
- }
- void wortspiegel(string &text, int pos)
- {
- string tmp_text;
- int start = 0, end = 0;
- tmp_text = text;
- for (int i = pos; i < text.length(); i++)
- {
- if (!(text[i] >= 'a' && text[i] <= 'z') && !(text[i] >= 'A' && text[i] <= 'Z')) {
- end = i - 1;
- break;
- }
- }
- for (int i = pos; i < text.length(); i--)
- {
- if (!(text[i] >= 'a' && text[i] <= 'z') && !(text[i] >= 'A' && text[i] <= 'Z')) {
- start = i + 1;
- break;
- }
- }
- for (int i = start; i <= end; i++)
- {
- cout << "i: " << i << endl << "das andere:" << end - (i - start) << endl;
- //text[i] = text[end - (i - start)];
- }
- }
- int wortspiegelMain()
- {
- int cursor = 0;
- string text = "Dies ist ein Satz. Und noch ein Satz.";
- string cursorLeiste = "";
- char command = 'b';
- cout << "Bitte geben Sie den Text ein: ? \n";
- //text = getText();
- do
- {
- cursorLeiste = "";
- cout <<text << endl;
- for (int i = 0; i <= text.length(); i++)
- {
- if (i == cursor) cursorLeiste += "*";
- else cursorLeiste += " ";
- }
- cout << cursorLeiste << endl;
- cout << "Befehl (l: links, r: rechts, s: spiegeln, q: Ende) ?";
- cin >> command;
- if (command == 'l' && cursor > 0) cursor -= 1;
- if (command == 'r' && cursor < text.length() - 1) cursor += 1;
- if (command == 's') wortspiegel(text, cursor);
- } while (command != 'q');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement