请问大神这个怎么解决??谢谢了
代码如下:
#include<stdio.h>
#include<stdlib.h>
struct student { //xtudent 学籍;
int c; //长
int k; //宽
int g; //高
char name[9]; //姓名
struct stdent *next;
};
typedef struct student student;
int main()
{
int n;
while (scanf("%d", &n))
{
if (n != -1) {
int j;
student *p_head, *p_rail, *p_st;
p_head = (student *)malloc(sizeof(student));
p_rail = p_head;
int lfn[9]; //储存体积
char *lfnch[10]; //用于储存要找的名字
for (j = 0; j < n; j++)
{
p_st = (student *)malloc(sizeof(student));
scanf("%d %d %d %s", &(p_st->c), &(p_st->k), &(p_st->g), p_st->name);
p_rail->next = p_st;
p_rail = p_st;
lfn[j] = (p_st->c)*(p_st->k)*(p_st->g); //把体积储存在数组中;
lfnch[j] = (p_st->name); //分别把名字储存在数组中;
}
int min = lfn[0], max = lfn[0],pos1,pos2;
for (j = 1; j < n; j++) //找到体积最大最小并标记下标;
{
if (min > lfn[j])
{
min = lfn[j];
pos1 = j;
}
else pos1 = 0;
if (max < lfn[j])
{
max = lfn[j];
pos2 = j;
}
}
printf("%s took clay from %s\n", lfnch[pos2], lfnch[pos1]);
min = 0, max = 0;
}
else
break;
}
return 0;
}