使用数组,使用每个元素的下标定位元素,逐个替换实现
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;
}
输出结果:
标签:XXX,LED,int,广告语,char,arr1,元素,底商,left From: https://blog.51cto.com/wurubin/7191418