题解 | #反序输出#
反序输出
http://www.nowcoder.com/practice/171278d170c64d998ab342b3b40171bb
本题需用low,high指针前后夹击字符串数组,在每一次循环的过程中将两字符进行交换即可
#include<stdio.h>
#include<cstring>
void reverse(char *s){
int low = 0,high = strlen(s)-1;
while(low <= high){
char temp;
temp = s[low];
s[low] = s[high];
s[high] = temp;
low++;
high--;
}
}
int main(){
char s[100];
while(scanf("%s",&s) != EOF){
reverse(s);
puts(s);
}
}