zoukankan      html  css  js  c++  java
  • 结构体学生成绩输入和输出

    Time Limit: 1 Sec  Memory Limit: 128 MB
    Submit: 186  Solved: 57
    [Submit][Status][Web Board]

    Description

    编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据,每个学生的数据包括num(学号)、name(姓名)、score[3](3门课的成绩)。编写一个函数input,用来输入5个学生的数据。

    Input

    5个学生的学号,姓名,3门课的成绩

    Output

    5个学生的学号,姓名,3门课的成绩

    Sample Input

    1001 zhangsan 100 90 86
    1002 lisi 90 20 80
    1003 wangwu 90 90 89
    1004 yanping 100 100 100
    1005 xiaoxiao 60 60 60

    Sample Output

    1001 zhangsan 100 90 86
    1002 lisi 90 20 80
    1003 wangwu 90 90 89
    1004 yanping 100 100 100
    1005 xiaoxiao 60 60 60
    #include<iostream>
    #include<string>
    using namespace std;
    struct student
    { int num;
    string n;
    int a[3];};
     void input(student *stu,int n )
     {int i;
     for(i=0;i<5;i++)
     {cin>>stu[i].num;
     cin>>stu[i].n;
     cin>>stu[i].a[0];
     cin>>stu[i].a[1];
     cin>>stu[i].a[2];}}
     void print(student *stu,int n )
    	 {int i;
     for(i=0;i<5;i++)
     {cout<<stu[i].num<<' ';
     cout<<stu[i].n<<' ';
     cout<<stu[i].a[0]<<' ';
     cout<<stu[i].a[1]<<' ';
     cout<<stu[i].a[2]<<endl;}}
    
    int main()
    
    
    {
    
    
        const int n=5;
    
    
        student stu[n];
    
    
        void input(student [],int );
    
    
        void print(student [],int );
    
    
        input(stu,n);
    
    
        print(stu,n);
    
    
        return 0;
    
    
    }
    
    

  • 相关阅读:
    jq 判断单选是否选中
    C# Split 分隔符为字符串及空格的处理
    MSSQL中的bit类型
    js 判断textarea 不为空
    [转]C#中out 及 ref 区别
    [转]asp.net中时间差的问题
    [转]C# Array 数组 及 一些操作
    Addr、@运算符与Pointer类型
    关于Pascal语言中的分号
    关于以后的文章
  • 原文地址:https://www.cnblogs.com/oversea201405/p/3767038.html
Copyright © 2011-2022 走看看