#include <stdio.h>
typedef struct
{ int num;
char name[9];
float score[3];
}STU;
void show(STU tt)
{ int i;
printf("%d %s : ",tt.num,tt.name);
for(i=0; i<3; i++)
printf("%5.1f",tt.score[i]);
printf("\n");
}
/**********found**********/
void modify(STU *ss,float a)//ss是指针结构体变量,前是STU
{ int i;
for(i=0; i<3; i++)
/**********found**********/
ss->score[i]*=a;//分数乘以a
}
void main( )
{ STU std={ 1,"Zhanghua",76.5,78.0,82.0 };
float a;
printf("\nThe original number and name and scores :\n");
show(std);
printf("\nInput a number : "); scanf("%f",&a);
/**********found**********/
modify(&std,a);//modify函数第一个变量是是指针结构体变量
printf("\nA result of modifying :\n");
show(std);
}
#include <stdio.h>
typedef struct
{ int num;
char name[10];
}PERSON;
/**********found**********/
void fun(PERSON std[])//下面是数组元素进行操作,应该用数组进行传参
{
/**********found**********/
PERSON temp;//应该和数组一个类型
if(std[0].num>std[1].num)
{ temp=std[0]; std[0]=std[1]; std[1]=temp; }
if(std[0].num>std[2].num)
{ temp=std[0]; std[0]=std[2]; std[2]=temp; }
if(std[1].num>std[2].num)
{ temp=std[1]; std[1]=std[2]; std[2]=temp; }
}
void main()
{ PERSON std[ ]={ 5,"Zhanghu",2,"WangLi",6,"LinMin" };
int i;
/**********found**********/
fun(std);//写数组名
printf("\nThe result is :\n");
for(i=0; i<3; i++)
printf("%d,%s\n",std[i].num,std[i].name);
}