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

编写代码演示多个字符从两端移动,向中间汇聚
#include<stdio.h>
#include<Windows.h>

int main()
{
	char a[] = "welcome to our school!";
	char b[] = "######################";
	int left = 0;
	int right = sizeof(a) - 2;//包含\0
	while (left <= right)//注意“=”奇数偶数有差别 要加=
	{
		Sleep(1000);
		b[left] = a[left];
		b[right] = a[right];
		left++;
		right--;
		printf("%s\n",b); 
		//printf("%s\r",b);

	}

	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/zn_wuxunian/article/details/79928205