#include#include //windows头文件 #include //standard library 标准库头文件 int main() { char arr1[] = "Welcome to JLU!!!!"; char arr2[] = "##################"; int left = 0; //int right = sizeof(arr1)/sizeof(arr1[0])-2;sizeof算 int right = strlen(arr1) - 1;//strlen不算 while (left <= right) { arr2[left] = arr1[left]; arr2[right] = arr1[right]; printf("%sn", arr2); //程序休眠1000ms Sleep(1000);//Sleep()是一个库函数,头文件是window.h //清空屏幕(clear screen) system("cls");//system()是一个库函数,执行系统命令,头文件是stdlib.h left++; right--; } printf("%sn", arr2); return 0; }
运行结果:
W################!
↓(时间间隔1000ms)
We##############!!
↓(时间间隔1000ms)
Wel############!!!
↓(时间间隔1000ms)
Welc##########!!!!
↓(时间间隔1000ms)
Welco########U!!!!
↓(时间间隔1000ms)
Welcom######LU!!!!
↓(时间间隔1000ms)
Welcome####JLU!!!!
↓(时间间隔1000ms)
Welcome ## JLU!!!!
↓(时间间隔1000ms)
Welcome to JLU!!!!
↓(时间间隔1000ms)
Welcome to JLU!!!!



