首页 > 其他分享 >多个字符从两端移动,向中间汇聚

多个字符从两端移动,向中间汇聚

时间:2023-02-26 17:32:51浏览次数:31  
标签:字符 right 两端 int 汇聚 char arr2 arr1 left

#include<stdio.h>
#include<string.h>

int main() {
char arr1[] = "welcome to bit!!!!!";
char arr2[] = "###################";
int left = 0;
int max = strlen(arr1);
int right = max - 1;

while (left<=right+2){
printf("%s\n", arr2);
arr2[left] = arr1[left];
arr2[right] = arr1[right];
right--;
left++;
}
return 0;
}

标签:字符,right,两端,int,汇聚,char,arr2,arr1,left
From: https://blog.51cto.com/u_13606048/6086647

相关文章