使用数组,使用每个元素的下标定位元素,逐个替换实现 int main() {char arr1[] = "XXX!Welcome To China!XXX";char arr2[] = " ";int left = 0;int right = strlen(arr1) - 1;while (left=right) {arr2[left] = arr1[left];arr2[ri
使用数组,使用每个元素的下标定位元素,逐个替换实现
int main() {
char arr1[] = "XXX!Welcome To China!XXX";
char arr2[] = " ";
int left = 0;
int right = strlen(arr1) - 1;
while (left<=right) {
arr2[left] = arr1[left];
arr2[right] = arr1[right];
Sleep(500);
system("cls");
left++;
right--;
printf("%s\n", arr2);
}
return 0;
}
输出结果: