rmoronsv

Untitled

Dec 19th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. main()
  2. {
  3. int c;
  4. int i = 0;
  5. char array[MAXARRAYSIZE];
  6. while ((c = getchar()) != '!')
  7. array[i++] = c;
  8. array[i] = '\0';
  9. reverse(array);
  10. printf("%s", array);
  11. }
  12. void reverse(char s[])
  13. {
  14. char temp[MAXARRAYSIZE];
  15. int i = 0;
  16. int j = 0;
  17. int pointofreverse = 0;
  18. while (s[i] != '\0' && s[i] != EOF)
  19. {
  20. while (s[i] != '\n' && s[i] != '\0' && s[i] != EOF)
  21. i++;
  22. pointofreverse = i - 1;
  23. while (j < i)
  24. temp[j++] = s[pointofreverse--];
  25. temp[j++] = s[i];
  26. if (s[i] != '\0')
  27. i++;
  28. }
  29. temp[j] = '\0';
  30. i = 0;
  31. while ((s[i] = temp[i]) != '\0')
  32. i++;
  33. }
  34.  
  35. main()
  36. {
  37. int c;
  38. int i = 0;
  39. char array[MAXARRAYSIZE];
  40. while ((c = getchar()) != '!')
  41. array[i++] = c;
  42. array[i] = '\0';
  43. reverse(array);
  44. printf("%s", array);
  45. }
  46. void reverse(char s[])
  47. {
  48. char temp[MAXARRAYSIZE];
  49. int i = 0;
  50. int j = 0;
  51. int pointofreverse = 0;
  52. while (s[i] != '\0' && s[i] != EOF)
  53. {
  54. while (s[i] != '\n' && s[i] != '\0' && s[i] != EOF)
  55. i++;
  56. pointofreverse = i - 1;
  57. while (j < i)
  58. temp[j++] = s[pointofreverse--];
  59. temp[j++] = s[i++];
  60. }
  61. temp[j] = '\0';
  62. i = 0;
  63. while ((s[i] = temp[i]) != '\0')
  64. i++;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment