5

演示多个字符从两边移动,向中间汇聚

 1 year ago
source link: https://blog.51cto.com/u_15927947/6007580
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

演示多个字符从两边移动,向中间汇聚

精选 原创

PicriL 2023-01-14 12:23:14 ©著作权

文章标签 #include 字符串 Windows 文章分类 其它 其它 阅读数214

#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;
}


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK