Chinaunix首页 | 论坛 | 博客
  • 博客访问: 816876
  • 博文数量: 321
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 936
  • 用 户 组: 普通用户
  • 注册时间: 2013-02-23 11:25
文章分类

全部博文(321)

文章存档

2017年(1)

2016年(10)

2015年(61)

2014年(187)

2013年(62)

分类: C/C++

2014-06-24 12:01:25

#include <stdio.h>
#include <stdlib.h>

struct student
{
    char number[6];
    char name[6];
    int score[3];
} stu[2];

void output(struct student stu[2]);

int main(int argc, char *argv[])
{
    int i, j;
    for(i = 0; i < 2; i++)
    {
        printf("请输入学生%d的成绩:\n", i + 1);
        printf("学号:");
        scanf("%s",stu[i].number);
        printf("姓名:");
        scanf("%s",stu[i].name);
        for(j = 0; j < 3; j++)
        {
            printf("成绩 %d. ",j + 1);
            scanf("%d", &stu[i].score[j]);
        }
        printf("\n");
    }
    output(stu);

    system("pause");
    return 0;
}

void output(struct student stu[2])
{
    int i, j;
    printf("学号 姓名 成绩1 成绩2 成绩3\n");
    for(i = 0; i < 2; i++)
    {
        printf("%-6s%-6s", stu[i].number, stu[i].name)    ;
        for(j = 0; j < 3; j++)
            printf("%-8d",stu[i].score[j]);
        printf("\n");
    }
}


阅读(307) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~