#include <stdio.h> #include <string.h> #include <Windows.h> #include <stdlib.h> int main() { char arr1[] = "welcome to China!!!"; char arr2[] = "################!!!"; int left = 0; //int right = sizeof(arr1) / sizeof(arr1[0]) - 2; 字符串末尾隐藏/0 所以要-2 int right = strlen(arr1) - 1; //要引头文件 while (left <= right) { arr2[left] = arr1[left]; arr2[right] = arr1[right]; printf("%s\n", arr2); Sleep(1000); //可以休息 一秒 system("cls"); //执行系统命令的函数-cls-清空屏幕 left++; right--; } return 0; }
加入Sleep会停顿一秒在打印