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;
    
    
    }
    
    

  • 相关阅读:
    每周总结
    5月2日学习日志
    5月1日学习日志
    4月30日学习日志
    4月29日学习日志
    4月28日学习日志
    4月27日学习日志
    每周总结
    vue滚动插件BetterScroll
    vue 获取页面高度
  • 原文地址:https://www.cnblogs.com/oversea201405/p/3767038.html
Copyright © 2011-2022 走看看