编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习4
#include <iostream>
#include <string>
using namespace std;
int main()
{
string fname;
string lname;
string name;
cout<<"Enter your first name: ";
getline(cin,fname);
cout<<"Enter your last name: ";
getline(cin,lname);
name=lname+", "+fname;
cout<<"Here's the information in a single string: "<<name<<endl;
system("pause");
return 0;
}
与使用char数组和头文件cstring中的函数比较,string对象和string中函数,操作简单,尤其对复杂的问题优势更加明显。
编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习4的更多相关文章
- 编程菜鸟的日记-初学尝试编程-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 ...
随机推荐
- 2019-3-9,Servlet转跳链接详解
//以下代码,可以传递request和response对象及其属性和变量至指定页面 request.getRequestDispatcher("showAttribut.jsp") ...
- PAT Basic 1073. 多选题常见计分法
题目内容 多选题常见计分法(20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 批改多选题是比较麻烦的事情,有 ...
- Ubuntu安装TensorFlow
使用清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/ 下载. 在主界面右侧找到[相关链接]->[使用帮助],然后在出现的页面左侧找到Tensor ...
- 【BZOJ3379】[Usaco2004 Open]Turning in Homework 交作业
题解: 比较容易想到二分答案+时间逆流 这样就变成了经典的路灯问题 f[a][b][0/1] 其实可以不用二分答案 根据倒着考虑我们会发现一定是先走旁边的再走中间的 计算到当前点+下课时间所需的最小时 ...
- PHP Manager 安装失败的解决方法, PHP Manager 1.4 for IIS 10,经验证支持windows server 2016版本
// 另有无需进行修改注册表的安装包,经测试最高支持Windows Server 2016 版本,下载地址如下: https://github.com/EnhWeb/PHPManager/tree/m ...
- OAuth2:隐式授权(Implicit Grant)类型的开放授权
适用范围 仅需临时访问的场景 用户会定期在API提供者那里进行登录 OAuth客户端运行在浏览器中(Javascript.Flash等) 浏览器绝对可信,因为该类型可能会将访问令牌泄露给恶意用户或应用 ...
- 【AtCoder】ARC075
ARC075 在省选前一天听说正式选手线画到省二,有了别的女选手,慌的一批,然后刷了一个ARC来稍微找回一点代码感觉 最后还是挂分了,不开心 果然水平退化老年加重啊 原题链接 C - Bugged 直 ...
- cmake与autoconf+automake
cmake与autoconf+automakes是同类的编译工具,本人常用的是cmake. 这有一篇对比的文章,记录一下. cmake与autoconf+automake的对比
- python_异常处理_断言
一.Python标准异常 常用异常 Exception 常规错误的基类 AttributeError 试图访问一个对象没有的属性 IOError 输入/ 输出异常,基本上是无法打开文件 ImportE ...
- Python学习(九) —— 正则表达式与re模块
一.正则表达式 定义:正则表达式是对字符串操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑. 正则表达 ...