Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdbool.h>
- void changeStr(char* str, size_t size) {
- char temp;
- for (int i = 0; i < size / 2; i++) {
- temp = str[i];
- str[i] = str[i + size / 2];
- str[i + size / 2] = temp;
- }
- printf("Результат: %s\n", str);
- }
- int main() {
- char str[100];
- printf("Введите строку:\n");
- fgets(str, sizeof(str), stdin);
- size_t size = strlen(str);
- if (str[size - 1] == '\n') {
- str[size - 1] = '\0';
- size--;
- }
- printf("Длина строки: %zu\n", size);
- if (size % 4 == 0) {
- changeStr(str, size);
- } else {
- printf("Длина не кратна 4");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement