#include "stdafx.h"
#include <string.h>
#include <iostream>
using namespace std;
void swap(char *p,char *q)
{
char temp = *p;
*p = *q;
*q = temp;
}
void Change(char *begin,char *end)
{
char *temp;
while(begin!=NULL && end!=NULL && begin<end)
{
swap(begin,end);
begin++;
end--;
}
}
void turn(char *p,int n)
{
if(p!= NULL)
{
int length = strlen(p);
char *beginStr = p;
char *sen = p+n;
char *endStr = p+length-1;
Change(beginStr,sen);
Change(sen+1,endStr);
Change(beginStr,endStr);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
char p[]="abcd1234";
turn(p,3);
cout<<p<<endl;
system("pause");
return 0;
}
#include <string.h>
#include <iostream>
using namespace std;
void swap(char *p,char *q)
{
char temp = *p;
*p = *q;
*q = temp;
}
void Change(char *begin,char *end)
{
char *temp;
while(begin!=NULL && end!=NULL && begin<end)
{
swap(begin,end);
begin++;
end--;
}
}
void turn(char *p,int n)
{
if(p!= NULL)
{
int length = strlen(p);
char *beginStr = p;
char *sen = p+n;
char *endStr = p+length-1;
Change(beginStr,sen);
Change(sen+1,endStr);
Change(beginStr,endStr);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
char p[]="abcd1234";
turn(p,3);
cout<<p<<endl;
system("pause");
return 0;
}