标签:改变 字符 屏幕 交换 pre %s [] log win
交换数组内容#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>//调用windows自带的函数
int main()
{
char arr1[] = "welcome to my blog!";
char arr2[] = "###################";
int left = 0;
int right = strlen(arr1) - 1;
//int right = sizeof(arr1)/sizeof(arr1[0])-2;计算数组最后元素的下标
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;
}
字符串可以改变
标签:改变 字符 屏幕 交换 pre %s [] log win
原文地址:https://blog.51cto.com/14233078/2368012