演示多个字符从两边移动,向中间汇聚
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.
演示多个字符从两边移动,向中间汇聚
精选 原创
#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;
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK