现在的位置: 首页 > 综合 > 正文

c语言结构体 求助

2013年10月22日 ⁄ 综合 ⁄ 共 588字 ⁄ 字号 评论关闭

#include<stdio.h>
#define N 5
struct student 
{
char num[6];
char  name[8];
int score[4];
}stu[N];
void  main()
{
void print(struct student stu[6]);
int i,j;
for(i=0;i<N;i++)
  {
    printf("ninput score of student %d:n",i+1);
    printf("No");
    scanf("%s",&stu[i].num);
    printf("Name:");
    scanf("%s",&stu[i].name);
    for(j=0;j<3;j++)
    {printf("score %d",j+1);
    scnaf("%d",&stu[i].score[j]);
    }
    printf("n");
    }
    print[stu];
}
void print(struct student stu[6])
{
int i,j;
printf("nNo.    name    score1   score 2      score 3 n   ");
for(j=0;j<N;j++)
printf("%5s%8s",stu[j].num,stu[j].name);
for(i=0;i<3;i++)
printf("%6d",stu[j].score[i]);
printf("n");

}

抱歉!评论已关闭.