编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习9
#include <iostream>
#include <string>
using namespace std;
struct CandyBar
{
//string kind;
char kind[20];
float weight;
double calory;
};
void Display(CandyBar ca,int n)
{
cout<<"The kind of ca["<<n<<"] is: "<<ca.kind<<endl;
cout<<"The weight of ca["<<n<<"] is: "<<ca.weight<<endl;
cout<<"The calory of ca["<<n<<"] is: "<<ca.calory<<endl;
}
int main()
{
int size;
cout<<"Enter the size of the array: ";
cin>>size;
cin.get();
CandyBar *ca=new CandyBar[size];
//getline(cin,ca[0].kind);
cin.get(ca[0].kind,20).get();
ca[0].weight=200;
ca[0].calory=100;//getline(cin,ca[1].kind);//
cin.get(ca[1].kind,20).get();
ca[1].weight=205;
ca[1].calory=105;//getline(cin,ca[2].kind);//
cin.get(ca[2].kind,20).get();
ca[2].weight=210;
ca[2].calory=110;
Display(ca[0],0);
Display(ca[1],1);
Display(ca[2],2);
system("pause");
return 0;
}
编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习9的更多相关文章
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9
#include <iostream> #include <fstream> #include <cstdlib> #include <string> ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习8
#include <iostream> #include <fstream> #include <cstdlib> const int SIZE=20; using ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7
#include <iostream> #include <string> #include <cctype> using namespace std; int m ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习6
#include <iostream> #include <string> using namespace std; const int MSIZE=100; struct j ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习5
#include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习4
#include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showm ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习3
#include <iostream> using namespace std; void showmenu(void) { cout<<"Please enter ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习2
#include <iostream> #include <cctype> using namespace std; const int MAXSIZE=10; int mai ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习1
#include <iostream>#include <cctype>using namespace std;int main(){ char ch; while((ch=c ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习9
#include <iostream>using namespace std;int main(){ int num; cout<<"Enter number of ...
随机推荐
- bootstrap的模拟单选按钮
<div class="btn-group" data-toggle="buttons" id="radio"> <lab ...
- Java链表和递归
删除链表的指定元素: public class ListNode { public int val; public ListNode next; public ListNode(int x){ val ...
- SSD垃圾回收
A complete GC typically:includes four steps: selecting some blocks that contain somestale data as vi ...
- WCF+Autofac 实现构造函数依赖注入
1.新建一个项目 2.要对WCF服务实现Autofac注入,需要实现2个接口,IInstanceProvider与IServiceBehavior,并让实现IServiceBehavior的类成为一个 ...
- WPF编程之找不到资源mainWindow.xaml
原文: WPF编程之找不到资源“window1.xaml”之谜 因为将启动窗口移动到了一个新建的文件夹中,启动调试时报找不到资源mainWindow.xaml,原来是App.xaml里面设置的启动窗口 ...
- Vue2.0 探索之路——生命周期和钩子函数的一些理解
前言 在使用vue一个多礼拜后,感觉现在还停留在初级阶段,虽然知道怎么和后端做数据交互,但是对于mounted这个挂载还不是很清楚的.放大之,对vue的生命周期不甚了解.只知道简单的使用,而不知道为什 ...
- Lazy<T> 延迟加载
namespace ConsoleAppTest { class Program { static void Main(string[] args) { Lazy<Student> stu ...
- 1.RN环境搭建,创建项目,使用夜神模拟调试
1.环境搭建(Yarn.React Native 的命令行工具(react-native-cli)) npm install -g yarn react-native-cli 具体参考 参见官方(中文 ...
- csv导入数据到mongodb3.2
mongoimport.exe -d paper -c paper K:\paper.csv --type csv -f id,name 数据库名 表名 文件所在位置 文件类型 ...
- Thinkphp框架网站 nginx环境 访问页面access denied
今日不熟一个tiinkphp框架网站的时候,由于服务器环境是centos6.5+nginx1.8,已经运行php商城项目很正常, 本以为一切比较简单,直接新建了项目文件夹,xftp上传了程序,并配置n ...