习题4:演示多个字符从两端移动 中间汇聚
#include<stdio.h>
#include<string.h>
#include<windows.h>
#include<stdlib.h>
int main()
{
int sl = strlen("welcome bit !!!!!!");//strlen()遇到\0会停止!!!
char arr1[] = "welcome bit !!!!!!";
char arr2[] = "##################";
int left = 0;
int right = sl - 1;
while (left<right)
{
arr2[left] = arr1[left];
arr2[right] = arr1[right];
left++;
right--;
printf("%s\n", arr2);
Sleep(500);
system("cls");
}
printf("welcome bit !!!!!!");
return 0;
}
注意:sleep() 单位为ms