Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #pragma once
  2.  
  3.  
  4. bool isLetter(char);
  5. void reverse(char*);
  6.  
  7.  
  8.  
  9.  
  10. #include <iostream>
  11. #include "azis.h"
  12.  
  13. using namespace std;
  14.  
  15.  
  16. int main() {
  17. char text[100];
  18. cin.getline(text, 99);
  19. cout << text << endl;
  20. reverse(text);
  21.  
  22. return 0;
  23. }
  24.  
  25.  
  26.  
  27. #include <iostream>
  28. #include "azis.h"
  29.  
  30. bool isLetter(char c) {
  31. return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
  32. }
  33.  
  34. void reverse(char* str) {
  35. unsigned cnt = 0;
  36. for (int i = 0; str[i - 1] != '\0'; i++) {
  37. if (isLetter(str[i])) {
  38. cnt++;
  39. }
  40. if (!isLetter(str[i])) {
  41. for (int j = 1; j <= cnt; j++) {
  42. std::cout << str[i - j];
  43. }
  44. std::cout << " ";
  45. }
  46. if (!isLetter(str[i])) cnt = 0;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement