问题:
1.反转字符串,比如str=“hello world!!!",反转后ret=“!!!dlrow olleh";
数组方式代码如下:
#include <stdio.h> #include <stdlib.h> #include <assert.h> char* reverse(char inp[],int size){ assert(inp != NULL && size>=0); //NULL代表空地址,null只是一个符号 int i=0,j=size-1; while(i<j){ char tmp=inp[i]; inp[i]=inp[j]; inp[j]=tmp; i++;j--; } return inp; } int main(){ char input[]={'h','e','l','l','o','!','!','