话不多说直接上代码
#include<stdio.h>
#include<windows.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char arr1[] = "welcome to my world";
char arr2[] = "###################";
int left = 0;//左下标
//int right = sizeof(arr1) / sizeof(arr1[0]) - 2;//右下标,减2的原因是因为存在\0,在数组中也算作一个(方法一)
int right = strlen(arr1) - 1;//strlen遇见\0停止,因此需要加上#include<string.h>
while (left <= right)
{
arr2[left] = arr1[left];
arr2[right] = arr1[right];
printf("%s\n", arr2);
Sleep(1000);//停顿一秒
system("cls");//清屏需要用#include<windows.h>
left++;
right--;
}
printf("%s\n", arr2);
return 0;
}
一步一步展示出文字😃🤩