#include <stdio.h>
struct student
{
int num;
char name[10];
int score[3];
};
void print(struct student *,int);
int main(int argc, char *argv[])
{
struct student stu[5],*p;
int i;
p = &stu;
for (i = 0; i < 5; i++)
{
printf("please input %d student info.\n",i + 1);
scanf("%d%s%d%d%d",&stu[i].num,&stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
}
printf("the source result:\n");
print(p,5);
system("pause");
return 0;
}
void print(struct student *p,int n)
{
struct student *stu;
int i;
for (stu = p; stu < p + n; stu++)
{
printf("num = %d ,name = %s , score[1] = %d ,score[2] = %d ,score[3] = %d\n",
stu->num,stu->name,stu->score[0],stu->score[1],stu->score[2]);
}
}
|