Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- bool isLetter(char);
- void reverse(char*);
- #include <iostream>
- #include "azis.h"
- using namespace std;
- int main() {
- char text[100];
- cin.getline(text, 99);
- cout << text << endl;
- reverse(text);
- return 0;
- }
- #include <iostream>
- #include "azis.h"
- bool isLetter(char c) {
- return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
- }
- void reverse(char* str) {
- unsigned cnt = 0;
- for (int i = 0; str[i - 1] != '\0'; i++) {
- if (isLetter(str[i])) {
- cnt++;
- }
- if (!isLetter(str[i])) {
- for (int j = 1; j <= cnt; j++) {
- std::cout << str[i - j];
- }
- std::cout << " ";
- }
- if (!isLetter(str[i])) cnt = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement