稍微改了改
#include <stdio.h>
#include <string.h>
#define N 10
typedef struct ss
{ char num[10];
int s;
} STU;
int fun(STU a[],int sz)
{
int i,min=0;
for(i=1;i<sz;i++)
{
min = (a[min].s > a[i].s)?i:min;//找到最小的元素的下标
}
return min;
}
int main (void)
{ STU a[N]={ {"A01",81},{"A02",89},{"A03",66},{"A04",87},{"A05",77},
{"A06",90},{"A07",79},{"A08",61},{"A09",80},{"A10",71} };
int i;
printf("***** The original data *****\n");
for (i=0;i<N;i++)printf("No=%s Mark =%d\n",a[i].num,a[i].s);
int min=fun (a,N);
printf ("***** THE RESULT *****\n");
printf ("The lowest:%s,%d\n",a[min].num,a[min].s);
return 0;
}
#include <stdio.h>
#include <string.h>
#define N 10
typedef struct ss
{ char num[10];
int s;
} STU;
int fun(STU a[],int sz)
{
int i,min=0;
for(i=1;i<sz;i++)
{
min = (a[min].s > a[i].s)?i:min;//找到最小的元素的下标
}
return min;
}
int main (void)
{ STU a[N]={ {"A01",81},{"A02",89},{"A03",66},{"A04",87},{"A05",77},
{"A06",90},{"A07",79},{"A08",61},{"A09",80},{"A10",71} };
int i;
printf("***** The original data *****\n");
for (i=0;i<N;i++)printf("No=%s Mark =%d\n",a[i].num,a[i].s);
int min=fun (a,N);
printf ("***** THE RESULT *****\n");
printf ("The lowest:%s,%d\n",a[min].num,a[min].s);
return 0;
}