又一出错程序备份:功能按照字符串大小排序输出
#include<stdio.h>
#include<string.h>
void main()
{
void cmp(char*x,char*y);
char *word[]={"Follow","Basicc","Greats","Fortra","Design"};
int i,j;
printf("the old Following is:\n");
for(i=0;i<5;i++)
puts(word[i]);
for(i=0;i<5;i++)
puts(word[i]);
for(j=0;j<4;j++)
{
for(i=0;i<4-j;i++)
{
cmp(word[i],word[i+1]);
}
}
printf("the New Following is:\n");
for(i=0;i<5;i++)
puts(word[i]);
}
void cmp(char*x,char*y)
{
char c[100],a[100],b[100];
if(strcmp(x,y)<0)
{
int i;
for(i=0;*(x+i)!='\0';i++)
c[i]=*(x+i);
c[i]='\0';
for(i=0;*(y+i)!='\0';i++)
*(x+i)=*(y+i);
*(x+i)='\0';
for(i=0;c[i]!='\0';i++)
*(y+i)=c[i];
*(y+i)='\0';
}
}
#include<stdio.h>
#include<string.h>
void main()
{
void cmp(char*x,char*y);
char *word[]={"Follow","Basicc","Greats","Fortra","Design"};
int i,j;
printf("the old Following is:\n");
for(i=0;i<5;i++)
puts(word[i]);
for(i=0;i<5;i++)
puts(word[i]);
for(j=0;j<4;j++)
{
for(i=0;i<4-j;i++)
{
cmp(word[i],word[i+1]);
}
}
printf("the New Following is:\n");
for(i=0;i<5;i++)
puts(word[i]);
}
void cmp(char*x,char*y)
{
char c[100],a[100],b[100];
if(strcmp(x,y)<0)
{
int i;
for(i=0;*(x+i)!='\0';i++)
c[i]=*(x+i);
c[i]='\0';
for(i=0;*(y+i)!='\0';i++)
*(x+i)=*(y+i);
*(x+i)='\0';
for(i=0;c[i]!='\0';i++)
*(y+i)=c[i];
*(y+i)='\0';
}
}
既然还有不甘心
就还没到放弃的时候~