C++读取字符串数据的两种方式

对于同样的样例输入:

ladder came tape soon leader acme RIDE lone Dreis peat

ScAlE orb eye Rides dealer NotE derail LaCeS DrIed

noel dire Disk mace Rob dries

方式1

#define LOCAL
#include<iostream>
using namespace std;
int main(){
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif string s;
while(cin>>s){
cout<<s<<endl;
}
}

样例输出

ladder

came

tape

soon

leader

acme

RIDE

lone

Dreis

peat

ScAlE

orb

eye

Rides

dealer

NotE

derail

LaCeS

DrIed

noel

dire

Disk

mace

Rob

dries

方式2

#define LOCAL
#include<iostream>
using namespace std;
int main(){
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif string s;
while(getline(cin,s)){
cout<<s<<endl;
}
}

样例输出:

ladder came tape soon leader acme RIDE lone Dreis peat

ScAlE orb eye Rides dealer NotE derail LaCeS DrIed

noel dire Disk mace Rob dries

最新文章

  1. git for windows 的默认工作路径(HOME)的设置以及Git与GitHub之间的SSH加密协议
  2. Copy 与MutableCopy的区别
  3. 20145204&amp;20145212信息安全系统实验一报告
  4. 用Java程序判断是否是闰年
  5. ZOJ 1455 Schedule Problem(差分约束系统)
  6. C#_Wpf_DataContex上下文整个类绑定
  7. 关于Eclispe插件开发起步(一)
  8. SSKeyChains的使用小节
  9. [PWA] 15. Using The IDB Cache And Display Entries
  10. (2015年郑州轻工业学院ACM校赛题) C 数列
  11. HTML5实现图片文件异步上传
  12. 数据库复习总结(2)-SQLServer的管理
  13. 使用 Travis CI 实现项目的持续测试反馈
  14. CHENGDU1-Python编程语言和PEP8规范
  15. 26-Python3 面向对象
  16. java.security.NoSuchAlgorithmException: AES KeyGenerator not available
  17. hbase简单操作
  18. mysql配置my.cnf文件,以及参数优化提升性能
  19. Python中让MySQL查询结果返回字典类型的方法
  20. 【Bugly安卓开发干货】Android APP 高速 Pad 化实现

热门文章

  1. 纯css面板插件,自适应,多样式
  2. python小练习2
  3. python itchat 微信开发
  4. layui分页
  5. 云计算之概念——IaaS、SaaS、PaaS、Daas
  6. QT的lineidet的光标问题
  7. Linux文件的I/O操作
  8. 第五周 day5 python学习笔记
  9. 读书笔记之JavaScript中的数据类型
  10. mysqlslap执行基准测试