33,311
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
using namespace std;
void paix(char*);
int main()
{
char str[10];
cout<<"please input char string:";
cin.getline(str,10);
paix(str);
cout<<str<<endl;
}
void paix(char str[])
{
char *p=&str[0];
char *q=&str[0];
char t;
for(;*p!='\0';(p)++)
{
q=(p)+1;
while(*q!='\0')
{
if(*p>*q)
{
t=*p;
*p=*q;
*q=t;
}
(q)++;
}
}
}