从两边往中间靠
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <Windows.h>
#include <stdlib.h>
int main()
{
char arr1[] = "The world is too dangerous";
char arr2[] = " ";
int left = 0;
int right = sizeof(arr1) / sizeof(arr1[0]) - 2;
//-2的原因是因为字符串最后收尾是\0,而这个\0也算一个底数
while (left < right)
{
arr2[left] = arr1[left];
arr2[right] = arr1[right];
printf("%s\n", arr2);
Sleep(1000);
system("cls");
left++;
right--;
}
printf("%s\n", arr2);
return 0;
}
一个一个打出来
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <Windows.h>
#include <stdlib.h>
int main()
{
char arr1[] = "The world is too dangerous" ;
char arr2[] = " " ;
int zs = sizeof(arr1) / sizeof(arr1[0]);
int left = 0;
int right = zs - 2;
int num1 = sizeof(arr1)-1;
while (left < num1)
{
arr2[left] = arr1[left];
printf("%s\n", arr2);
Sleep(100);
system("cls");
left++;
}
printf("%s\n", arr2);
return 0;
}
*
原创
©著作权归作者所有:来自51CTO博客作者qaq2333的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论