Write a piece of code to demonstrate that multiple characters move from both ends to converge in the middle

Write a piece of code to demonstrate that multiple characters move from both ends to converge in the middle

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <Windows.h>//The main function of Sleep()
#include <stdlib.h>// The main function of system() Function
int main()
{ char arr1[] = "welcome to ShenZhen!!!"; char arr2[] = "####################"; int left = 0; int right = strlen(arr1)-1; while (left <= right) { arr2[left] = arr1[left]; arr2[right] = arr1[right]; printf("%s\n" , arr2); Sleep(1000);//After outputting, take a one-second rest system("cls");//Clear the screen function left++; right–; } printf("%s\n", arr2); system(" pause”); return 0; }

















Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_54748281/article/details/113484730