写补充的地方都要补充程序
【输入】
2
1 john b 16
2 Anna g 15
【输出】
john 16
anna 15
补充程序片段,如何使程序正确运行
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- qfl_sdu 2021-09-09 02:12关注
代码补全如下:
如有帮助,请帮忙采纳一下,谢谢。#include <iostream> #include <string> using namespace std; struct astudent { int id; string sname; int age; char sex; void inc() { age++; } //输出 void prn() { cout << id << ' ' << sname << ' ' << sex << ' ' << age << ' ' << endl; } void read() { //补充 cout << "请输入学生的学号、姓名、年龄、性别(F/M)" << endl; cin >> id >> sname >> age >> sex; } }; int main() { int n; astudent *istu; cin >> n; //创建 //补充 istu = new astudent[n]; for (int i = 0;i<n;i++) { istu[i].read(); } //所有的涨一岁 //补充 for (int i = 0;i<n;i++) { istu[i].inc(); } //输出 for (int i=0;i<n;i++) { //补充 cout << istu[i].sname << ' ' << istu[i].age << endl; } //销毁动态创建的数组 //补充 delete[] istu; istu = 0; return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 基于卷积神经网络的声纹识别
- ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
- ¥100 为什么这个恒流源电路不能恒流?
- ¥15 有偿求跨组件数据流路径图
- ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
- ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
- ¥15 CSAPPattacklab
- ¥15 一直显示正在等待HID—ISP
- ¥15 Python turtle 画图
- ¥15 stm32开发clion时遇到的编译问题