编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习6
#include <iostream>
#include <string>
using namespace std;
struct car
{
string pro;
int year;
};
int main()
{
int num;
cout<<"How many cars do you wish to catalog? ";
(cin>>num).get();//注意将输入后的回车键转换成的换行符读取并丢弃
car *newcar=new car[num];
for(int i=0;i<num;i++)
{
cout<<"Car #"<<i+1<<":"<<endl;
cout<<"Please enter the make: ";
getline(cin,newcar[i].pro);
cout<<"Please enter the year made: ";
(cin>>newcar[i].year).get();//注意将输入后的回车键转换成的换行符读取并丢弃
cout<<"Here is your collection:"<<endl;
for(int j=0;j<num;j++)
cout<<newcar[j].year<<" "<<newcar[j].pro<<endl;
delete [] newcar;//删除开辟的动态空间
system("pause");
return 0;
}
编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习6的更多相关文章
- 编程菜鸟的日记-初学尝试编程-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 ...
随机推荐
- ASP.NET知识点汇总
一 ,html属性20181113常用的居中方法1 text-align2 float3 margin (margin-left matgin-right margin-bottom margin-t ...
- [Android] Android Java String 转Uri
Uri uri = Uri.parse("https://www.baidu.com") URI uri = new URI("https://www.baidu.com ...
- SQL Server 常用的系统函数
Ø 简介 本文主要列举 SQL Server 中常用的一些系统函数,帮助我们在编写 SQL 时忘了某个函数的用法方便查阅.主要分为以下几类函数,更多函数可参考官网. 1. 字符串函数 2. ...
- 多人聊天室(Java)
第1部分 TCP和UDP TCP:是一种可靠地传输协议,是把消息按一个个小包传递并确认消息接收成功和正确才发送下一个包,速度相对于UDP慢,但是信息准确安全:常用于一般不要求速度和需要准确发送消息的场 ...
- EffectiveC++ 第3章 资源管理
我根据自己的理解,对原文的精华部分进行了提炼,并在一些难以理解的地方加上了自己的"可能比较准确"的「翻译」. Chapter 3 资源管理 条款13: 以对象管理资源 有时即使你顺 ...
- 🍓 DOM常用基础知识点汇总(入门者适用) 🍓
铛-今天又没啥事,来总结一下DOM的基础知识.(公司没活干我也很无奈
- 网络学习day03_IP地址概述与应用
IP地址 IP地址的定义及分类 主机唯一的标识,保证主机间正常通信 一种网络编码,用来确定网络中一个节点 IP地址是一个32位的二进制数 常见的IP地址,分为IPv4与IPv6两大类. ipv4的形式 ...
- WebService - [Debug] java.net.BindException: Can't assign requested address
Connected to the target VM, address: '127.0.0.1:57803', transport: 'socket' Exception in thread &quo ...
- tmux 后台训练
参考链接:https://blog.csdn.net/u014381600/article/details/54588531
- 第一天 Requests库入门
Requests库的get()方法 requests.get(url, params=None, **kwargs) ∙ url : 拟获取页面的url链接 ∙ params : url中的额外参数, ...