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