Advertisement
qberik

Untitled

Nov 16th, 2021
49
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4. using namespace std;
  5.  
  6. char *F(char str[]);
  7.  
  8. int main()
  9. {
  10. SetConsoleCP(1251);
  11. SetConsoleOutputCP(1251);
  12.  
  13. char str[30]{};
  14. cout << "Введите строку:\n";
  15. cin.getline(str, 30);
  16. cout << "Ваш ответ равен:" << F(str) << endl;
  17. return 0;
  18. }
  19.  
  20. char *F(char str[])
  21. {
  22. int i{}, j{};
  23. char temp1[30]{};
  24. char *temp2;
  25. bool flag = false;
  26. //for (i = 0; i < strlen(str); i++)
  27. while( str[i] != '\0' )
  28. {
  29. if (str[i] == ';') flag = true;
  30. i++;
  31. }
  32. if (flag)
  33. {
  34. i = 0;
  35. while (str[i] != ';')
  36. {
  37. temp1[i] = str[i];
  38. i++;
  39. }
  40. temp2 = F( ( str + i + 1 ) );
  41. while (str[j] != '\0')
  42. {
  43. str[j] = *temp2;
  44. temp2++;
  45. j++;
  46. }
  47. j -= ( i + 1 );
  48. for (int k = 0; k < i; k++)
  49. {
  50. str[j++] = temp1[k];
  51. }
  52. str[j] = '\0';
  53. }
  54. return str;
  55. }
  56.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement