zoukankan      html  css  js  c++  java
  • 输入两位学生的学号姓名 以及三门成绩 并输出

     1 /* 输入学生成绩并显示 */
     2 # include <stdio.h>
     3 
     4 struct student
     5 {
     6     char number[6];
     7     char name[6];
     8     int  score[3];
     9 } stu[2];
    10 
    11 void output(struct student stu[2]);
    12 
    13 void main()
    14 {
    15     int i, j;
    16     for(i=0; i<2; i++)
    17     {
    18         printf("请输入学生%d的成绩:
    ", i+1);
    19         printf("学号:");
    20         scanf("%s", stu[i].number);
    21         printf("姓名:");
    22         scanf("%s", stu[i].name);
    23         for(j=0; j<3; j++)
    24         {
    25             printf("成绩 %d.  ", j+1);
    26             scanf("%d", &stu[i].score[j]);
    27         }
    28         printf("
    ");
    29     }
    30     output(stu);
    31 }
    32 
    33 void output(struct student stu[2])
    34 {
    35     int i, j;
    36     printf("学号  姓名  成绩1  成绩2  成绩3
    ");
    37     for(i=0; i<2; i++)
    38     {
    39         printf("%-6s%-6s", stu[i].number, stu[i].name);
    40         for(j=0; j<3; j++)
    41             printf("%-8d", stu[i].score[j]);
    42         printf("
    ");
    43     }
    44 }
  • 相关阅读:
    putty GB18030乱码
    iptables小复习
    编译安装 openswan-2.6.34
    Windows常用的命令
    MySql实现远程连接
    防盗链
    java判断一个类是否公共类
    oracle sql性能
    状态模式让我们远离战战兢兢
    LVM管理
  • 原文地址:https://www.cnblogs.com/liugangjiayou/p/11616370.html
Copyright © 2011-2022 走看看