标签:++ string cin.get double mil prim style name int
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; }
标签:++ string cin.get double mil prim style name int
原文地址:https://www.cnblogs.com/lightmonster/p/10320227.html