问题描述:有一个字符数组的内容为:"student a am i",请你将数组的内容改为"i am a student".
代码实现:
#include <stdio.h> void swap(char *a,char *b) { *a = *a + *b; *b = *a - *b; *a = *a - *b; } void reverse(char *arr,int left,int right)//student a am i { while(left < right) { swap(&arr[left],&arr[right]);//arr[0] left++; right--; } } int main() { int left = 0; int right = 0; char arr[]="student a am i"; reverse(arr,0,sizeof(arr)/sizeof(arr[0])-2);//student while(arr[right] != '