编译代码,演示多个字符从两端移动,向中间汇聚。

#include<stdio.h>
#include<string.h>
#include<windows.h>

int main()
{
	char arr[] = "hello world";
	char arr2[] = "###########";
	int right = strlen(arr) - 1;
	int left = 0;
	printf("%s\n",arr2);
	while (left <= right)
	{
		Sleep(1000);
		arr2[left] = arr[left];
		arr2[right] = arr[right];
		left++;
		right--;
		printf("%s\n",arr2);
	}
}

猜你喜欢

转载自blog.csdn.net/weixin_62839396/article/details/121207228