ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 结构类型数组实验 c程序设计 题解与上机指导 PAST

结构类型数组实验 c程序设计 题解与上机指导 PAST

原创 Linux操作系统 作者:czhaii 时间:2012-08-28 23:38:14 0 删除 编辑
主题:结构类型数组实验 c程序设计 题解与上机指导 PAST
 //2012 8 27 20::01
 
                  #include                   
                  #include
                 
                  const 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                     {
                      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);
                        scanf("%d",&stu[i].score[j]);
                       }
                         printf("\n");
                     }
                     print(stu);
                   }
                   void print(struct student stu[6])
                   {
                    int i,j;
                    printf("\n No. name score1 score2    score3\n");
                    for(i=0;i                    {
                       printf("%5s%10s",stu[i].num,stu[i].name);
                       for(j=0;j<3;j++)
                       printf("%9d",stu[i].score[j]);
                       printf("\n");
     }                     
       }
 
 
 


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27660822/viewspace-742103/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-08-22

  • 博文量
    22
  • 访问量
    55903