编程菜鸟的日记-初学尝试编程-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 ...
随机推荐
- SpringMVC之使用ResponseEntity,java接口返回HttpStatus
Post请求 一般情况下,在非必须的情况下,使用Jquery实现post请求,而后台返回一般都需要手动封装ResponseUtil,和使用@ResponseBody注解来实现返回.然而我们书上学到的关 ...
- PyOpenCV图像逆时针旋转90度
warpAffine方法效果很搓,留下大片黑色区域. 使用flip和transpose可以实现逆时针旋转90度.先flip或先transpose均可. #coding:utf-8 import cv2 ...
- python--使用递归优雅实现列表相加和进制转换
咦,好像坚持了一段时间,感觉又有新收获啦. # coding: utf-8 class Stack: def __init__(self): self.items = [] # 是否为空 def is ...
- 使用Docker方式运行Mysql(MariaDB)
两者差不多.我使用的是MariaDB. 下面的docker命令,挂了数据,配置,映射了端口,指定了root密码,服务端编码. 蛮快的! docker run \ --name mariadb \ -v ...
- Hadoop集群最迅速的配置免密码登陆方法
1:多台机器互相免密登陆的思路(默认你的linux操作系统已经安装好ssh): 第一步:在各自的机器上面生成密钥: 在第1台机器上生产一对钥匙: ssh-keygen -t rsa 在第2台机器上生产 ...
- Refs & DOM
Refs 提供了一种访问在 render 方法中创建的 DOM 节点或 React 元素的方式. 在典型的 React 数据流中, 属性(props)是父组件与子代交互的唯一方式.要修改子组件,你需要 ...
- 用Web api /Nancy 通过Owin Self Host简易实现一个 Http 服务器
过去做 端游的Http 服务器 用的WebApi 或者Mvc架构,都是放在iis...而我已经是懒出一个地步,并不想去配iis,或者去管理iis,所以我很喜欢 Self host 的启动方式. C#做 ...
- maven安装和eclipse集成
maven作为一个项目构建工具,在开发的过程中很受欢迎,可以帮助管理项目中的bao依赖问题,另外它的很多功能都极大的减少了开发的难度,下面来介绍maven的安装及与eclipse的集成. maven的 ...
- Nginx动静分离
动静分离 Nginx动静分离是让动态网站里的动态网页根据一定规则把不变的资源和经常变的资源区分开来,动静资源做好了拆分以后,我们就可以根据静态资源的特点将其做缓存操作,这就是网站静态化处理的核心思路. ...
- python全栈开发day66-视图系统、路由系统
一.昨日内容回顾 1. tags 1. for循环 {% for name in name_list %} {{ name }} {% endfor %} {% for name in name_li ...