标签:int 直接 ring index rev char 实现 class bsp
1. i am a student《=》tneduts a ma i 两边对称
void flipString(char*arr,int highIndex) { if(highIndex==0){ return; } int lowIndex = 0; while (lowIndex < highIndex) { char tmp = arr[highIndex];//数组内容进行翻转 arr[lowIndex] = arr[lowIndex]; arr[right] = tmp; highIndex--; lowIndex++; } }
2. i am a student =>student a am i
第一步直接调用flipString,实现 i am a student =》tneduts a ma i=》student a am i
第二步实现单词的翻转。
reverseWord(char* arr, int len){ int lowIndex = 0 while(arr[lowIndex] !=‘\0‘){ if(arr[lowIndex]==‘ ‘){ } } }
标签:int 直接 ring index rev char 实现 class bsp
原文地址:https://www.cnblogs.com/shijianchuzhenzhi/p/12717379.html