VC6.0下编译运行,结果无误。
#include
#include
using namespace std;
void temp(char *str[])
{
for (int i=0; i<5; i++)
{
for (int j=1; j<5-i; j++)
{
if ( strcmp(str[j-1],str[j]) > 0 )
{
char *tmp = str[j-1];
str[j-1] = str[j];
str[j] = tmp;
}
}
}
}
int temp1(char *p,char *str[])
{
for (int i=0; i<5; i++)
{
if ( strcmp(p,str[i]) == 0 )
{
return 1;
}
}
return 0;
}
void main()
{
char *str[5]={"abcde","xfghek","dfjdsiei","nice","zfdd"};
temp(str); //调用排序函数
cout<<"按序结果:"<
{
cout<
char *p = "nice";
cout<