- #include<iostream.h>
- #include<string.h>
- int main()
- {
- char *s,*p,*q;
- int x,t;
- s=new char[20];
- cin>> s;
- cout <<s;
- x=strlen(s);
- p=s+x-1;
- q=s;
- for(int i=0;i <x/2;i++)
- { t=*q;
- *q=*p;
- *p=t;
- p--;
- q++;
- }
- cout <<s;
- cin>> x;
- return 0;
- }
- #include<stdio.h>
- char *revstr(char *str)
- {
- char ch;
- char *left=str;
- char *start=str;
- while(*str!='/0')
- {
- str++;
- }
- str--;
- while(left<str)
- {
- ch=*str;
- *str=*left;
- *left=ch;
- left++;
- str--;
- }
- return start;
- }
- main()
- {
- char p[]="aaabbcc";
- char *out;
- out=revstr(p);
- printf("%s/n",out);
- }