Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define ALPHA true
- #define MISC false
- char toLower(char ch)
- {
- if (ch >= 'A' && ch <= 'Z') {
- return ch - 'A' + 'a';
- } else {
- return ch;
- }
- }
- bool isAlpha(char ch)
- {
- return (ch >= 'a' && ch <= 'z') || ch == '\'';
- }
- int main()
- {
- char words[256][80] = { '\0' };
- int idx = -1;
- int cursor = 0;
- char buf;
- bool state = MISC;
- while (cin.get(buf) && buf != '@') {
- char ch = toLower(buf);
- if (isAlpha(ch)) {
- if (state == MISC) {
- idx++;
- }
- state = ALPHA;
- words[idx][cursor] = ch;
- cursor++;
- } else {
- state = MISC;
- cursor = 0;
- }
- }
- for (int i = 0; i <= idx; i++) {
- cout << words[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement