首页 > 编程语言 > 详细

C++Primer Plus习题记录-Chapter8

时间:2019-01-25 16:28:01      阅读:168      评论:0      收藏:0      [点我收藏+]

7-2

#include "pch.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cctype>
#include <array>
#include <iomanip>

using namespace std;
struct CandyBar
{
    string brand;
    double weight;
    int heat;
};
void info_candy(CandyBar &changed_para, char* str, double m, int n);
void show(CandyBar &candy);//test

int main() {
    CandyBar init_para = {
        "Millennium Munch",
        2.85,
        350
    };
    show(init_para);
    char ch[20];
    cin.getline(ch,20);
    double m;
    cin >> m;
    int n;
    cin >> n;
    info_candy(init_para, ch, m, n);
    show(init_para);
    return 0;
}
void info_candy(CandyBar &changed_para, char* str, double m, int n) {
    changed_para.brand = str;
    changed_para.weight = m;
    changed_para.heat = n;
}
void show(CandyBar &candy) {
    cout << candy.brand << "\n" << candy.weight << "\n" << candy.heat << endl;
}

 

C++Primer Plus习题记录-Chapter8

原文:https://www.cnblogs.com/lightmonster/p/10320227.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!