cin流的状态和缓存刷新问题
2008-03-14 09:51
232 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "stdafx.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <iostream>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <list>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <vector>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <limits>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using namespace std;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
int main(void)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
vector <int> ivec;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
list <int> ilst;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int ival;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout << "the vetor's numbers" << endl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
while(cin >> ival)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ivec.push_back(ival);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cin.clear(); //注意此处
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cin.ignore(std::numeric_limits<streamsize>::max(),' ');//此处关键
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout << "the list's numbers" << endl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
while(cin >> ival)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ilst.push_back(ival);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
vector <int> ::const_iterator vecit = ivec.begin();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
list <int> ::const_iterator lstit = ilst.begin();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(ilst.size() != ivec.size())
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout << "they are not same" << endl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for( ; vecit != ivec.end(), lstit != ilst.end(); ++vecit, ++lstit)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(*vecit != *lstit)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout << "they are not same" << endl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout << "they are same!" << endl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
相关文章推荐
- Flex页面刷新问题——HttpService缓存问题
- 关于easy可编辑表格树表格刷新和加载状态问题
- ios添加缓存后界面刷新崩溃问题
- php+ajax实时刷新数据库信息遇到的缓存问题
- iframe缓存不刷新问题彻底解决方法
- IE9下Ajax无法刷新数据的缓存问题解决方法
- 网页中通过js修改img的src属性刷新图片时,图片缓存问题现象表述及问题解决
- 关于AJAX请求服务器后缓存数据,造成没有及时刷新的问题
- [KnowHow]WPF中Button状态不刷新的问题[Lianz]
- 浏览器开发前端工程,刷新缓存问题
- jQuery getJSON在IE下不刷新,缓存的问题
- iframe缓存不刷新问题彻底解决方法
- AJAX技巧及问题(如何去除AJAX取过值后IE的缓存及取得xmlHttp.status状态时为空问题,在AJAX中如何传递中文)
- ajax页面无刷新 IE下遭遇Ajax缓存导致数据不更新的问题
- 关于火狐浏览器checkbox选中状态刷新后无变化的问题
- 在Asp.net 2.0 中禁用页面缓存解决页面刷新(重新加载数据)的问题!
- SSH Ajax 页面缓存 页面刷新问题 以及缓存技术讲解
- window.showModalDialog方式/模式窗口数据不刷新(缓存)问题
- php 文件状态缓存带来的问题
- php 文件状态缓存带来的问题