C语言多个字符从两端移动向中间汇聚

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>                                            //调用Sleep函数
int main(){
	char str1[] = "welcome to Beijing!";
	char str2[] = "###################";
	int left = 0;
	int right = strlen(str1) - 1;
	while (left <= right){
		printf("%s\n",str2);
		str2[left] = str1[left];
		str2[right] = str1[right];
		++left;
		--right;
		Sleep(300);
		system("cls");
	}
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44781107/article/details/88808261