# re: 冒泡排序算法描述 回复 更多评论
2006-12-11 14:57 by
#include "stdio.h"
#define N sizeof tb1/sizeof(tb1[0])
int A,B,C,D,E,F;
struct ele{
char vn;
int *vp;
}tb1[]={{'A',&A},{'B',&B},{'C',&C},{'D',&D},{'E',&E},{'F',&F}},t;
int main()
{
int k,m,j;
for(k=0;k<N;k++)
{
printf("Enter data for %c\n",tb1[k].vn);
scanf("%d",tb1[k].vp);
}
m=N-1;
while(m>0)
{
k=0;
for(j=0;j<m;j++)
if(tb1[j].vp<tb1[j+1].vp)
{
t=tb1[j];
tb1[j]=tb1[j+1];
tb1[j+1]=t;
k=j;
}
m=k;
}
printf("%d\n",m);
for(k=0;k<N;k++)
printf("%c(%d)",tb1[k].vn,*tb1[k].vp);
return 0;
}
我也是这样写的怎么不对丫??您帮我看一下吧 .谢谢