非常简单!

来源:百度知道 编辑:UC知道 时间:2024/05/29 11:17:34
给句子排序:
Wu Ping Wei Fang are and chess playing .
要快哦!

Wu Ping and Wei Fang are playing chess。

Wu Ping and Wei Fang are playing chess

Wei Fang and Wu Ping are playing chess。

是问c程序吗?这问题问得不太清楚啊,如果是c程序,就下面这样,在vc++6.0里面运行。

#include <stdio.h>
#include <string.h>
main()
{
void sort(char**pc,int n);
char**pc,*pa[]={"Wu","Ping","Wei","Fang","are","and","chess","playing"};
pc=pa;
sort(pc,8);
printf("These new strings are:\n");
for(;pc<pa+8;pc++)
{
printf("%s\n",*pc);
}
}

void sort(char**pc,int n)
{
int i,j;
char*term;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(strcmp(*(pc+i),*(pc+j))>0)
{
term=*(pc+i);
*(pc+i)=*(pc+j);
*(pc+j)=term;
}
}
}
}

printf("wu ping and wei fan