Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1567624
  • 博文数量: 354
  • 博客积分: 8137
  • 博客等级: 中将
  • 技术积分: 5137
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-26 15:40
文章分类

全部博文(354)

文章存档

2010年(300)

2009年(54)

分类: C/C++

2010-06-29 14:02:07

#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");
    }
}


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