/*
百度笔试题:
编程:
用C语言实现一个revert函数,它的功能是将输入的字符串在原串上倒序后返回。
*/
#include<stdio.h>
void f(char* s){
if(*s=='\0')
return;
char temp;
char* end=s;
while(*((++end))!='\0');
end--;
char* start=s;
while(start<end){
temp=*start;
*(start++)=*end;
*(end--)=temp;
}
}
int main(){
char a[10]="123456789";
f(a);
puts(a);
char b[1]="";
f(b);
puts(b);
}
百度笔试题:
编程:
用C语言实现一个revert函数,它的功能是将输入的字符串在原串上倒序后返回。
*/
#include<stdio.h>
void f(char* s){
if(*s=='\0')
return;
char temp;
char* end=s;
while(*((++end))!='\0');
end--;
char* start=s;
while(start<end){
temp=*start;
*(start++)=*end;
*(end--)=temp;
}
}
int main(){
char a[10]="123456789";
f(a);
puts(a);
char b[1]="";
f(b);
puts(b);
}