qq_45955222 2019-12-01 19:42 采纳率: 0%
浏览 5543

c++结构体输入并输出学生信息

c++ 运用结构体,录入学生姓名年龄性别成绩等信息,用new申请内存,用一个子函数input输入,display输出

  • 写回答

1条回答 默认 最新

  • dut小冯 2019-12-01 20:11
    关注

    #include "stdafx.h"
    #include
    #include
    #include
    using namespace std;
    struct Student {
    string name;
    int age;
    string sexual;
    int score;
    };
    void input(Student *S) {
    cin >> S->name;
    cin >> S->age;
    cin >> S->sexual;
    cin>> S->score;
    }
    void display(Student *S) {
    cout << S->name <<"\n"<age << S->sexual <<"\n"<< S->score << endl;
    }
    int main()
    {
    Student *stu=new Student;
    input(stu);
    display(stu);
    delete stu;
    return 0;
    }

    评论

报告相同问题?

悬赏问题

  • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理
  • ¥15 操作系统相关算法中while();的含义
  • ¥15 CNVcaller安装后无法找到文件
  • ¥15 visual studio2022中文乱码无法解决
  • ¥15 关于华为5g模块mh5000-31接线问题
  • ¥15 keil L6007U报错
  • ¥15 webapi 发布到iis后无法访问
  • ¥15 初学者如何快速上手学习stm32?
  • ¥15 如何自动更换布娃娃图片上的衣服
  • ¥15 心理学eprime编程