#include<stdio.h>
#include<string.h>
#include<conio.h>
int main() {
char str[100];
printf("\nNhap vao 1 chuoi bat ky :");
gets_s(str);
int temp = 0;
int n = strlen(str) - 1;
for (int fl = 0; fl <= n; fl++)
{
int count = temp;
int num1 = 1;
// Lấy từ trước khoảng trắng hoặc từ cuối
if (str[fl] == ' ' || fl == n)
{
if (fl == n)
{
for (int c = fl; c >= temp; c--)
{
// Hoán vị
if (num1 <= (fl - temp) / 2)
{
char tempC = str[count];
str[count] = str[c];
str[c] = tempC;
count++;
num1++;
}
}
}
else
{
for (int c = fl - 1; c >= temp; c--)
{
if (num1 <= (fl - temp) / 2)
{
char tempC = str[count];
str[count] = str[c];
str[c] = tempC;
count++;
num1++;
}
}
}
temp = fl + 1;
}
}
printf("\nDao lai la :%s", str);
_getch();
return (0);
}