加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

编写一个函数input,用来输入5个学生的数据记录。

(2010-06-21 13:41:09)
标签:

杂谈

分类: 计算机及相关应用

编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据记录,每个记录包括num、names、score[3],编写一个函数input,用来输入5个学生的数据记录,用print函数输出这些记录。

#include<stdio.h>
struct student
{
   char num[5];
   char name[10];
   int score[3];
}stu[5];

void main()
{
 void input();
 void print(student stu[5]);
   input();
   print(stu);
 }

void print(student stu[5])
{
 int i,j;
   printf(" No.    name   score1   score2   score3\n");
   for (i=0;i<5;i++)
   {
   printf("%5s%8s",stu[i].num,stu[i].name);
   for (j=0;j<3;j++)
   printf("%9d",stu[i].score[j]);
   printf("\n");
   }
}


void input()
{
int i,j;
   for (i=0;i<5;i++)
{
   printf("input 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]);
   }
}
}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有