输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成

happyfirst_2009 2009-09-29 10:20:44
如题...
怎么写这个的一个代码呢?
cin>>year>>"/">>month>>"/">>day
这样子好像不行的哦```
...全文
980 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
mymtom 2009-09-30
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 omegabomb 的回复:]
学习,问问blash是什么意思?
[/Quote]
英语太差了,
应该改为slash 也就是斜线的意思。
thy38 2009-09-30
  • 打赏
  • 举报
回复
又是一个0.00%
omegabomb 2009-09-29
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 mymtom 的回复:]
C/C++ code
#include<iostream>usingnamespace std;int
main(int argc,char*argv[])
{int year, month, day;char blash;while (cin>> year>> blash>> month>> blash>> day) {
cout<< year<< blash<<¡­
[/Quote]
blash只是存入了"/",当2次输入的blash不同时,就会取后面那次的结果。
omegabomb 2009-09-29
  • 打赏
  • 举报
回复
学习,问问blash是什么意思?
mymtom 2009-09-29
  • 打赏
  • 举报
回复

cat 066.txt
2001/01/01
2009/01/01
2009/09/01



cat 066.txt | ./066
2001/1/1
2009/1/1
2009/9/1
mymtom 2009-09-29
  • 打赏
  • 举报
回复

#include <iostream>
using namespace std;

int
main(int argc, char *argv[])
{
int year, month, day;
char blash;

while (cin >> year >> blash >> month >> blash >> day) {
cout << year << blash << month << blash << day << endl;
}
return 0;
}
happyfirst_2009 2009-09-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 kouwenlong 的回复:]
cin好像没有那种功能吧。
用scanf吧。
C/C++ codeint year,month,day;
scanf("%d/%d/%d",&year,&month,&day);
[/Quote]
没有C++的写法吗?
kouwenlong 2009-09-29
  • 打赏
  • 举报
回复
cin好像没有那种功能吧。
用scanf吧。
int year,month,day;
scanf("%d/%d/%d", &year, &month, &day);
kouwenlong 2009-09-29
  • 打赏
  • 举报
回复
记得结贴。

64,647

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧