新微赢技术网

标题: [求助]这个cin哪里错了 [打印本页]

作者: 森林的眼泪    时间: 2009-11-3 02:47
标题: [求助]这个cin哪里错了
程序有点长,,编译无错误,主要是在红色字处要进行cin输入时,
#include <iostream>
#include <set>
#include <vector>
#include <string>
using namespace std;
void readBook()
{
vector<string> bookVec;
set<string> readSet;
readSet.insert("ThinkinginC++");
readSet.insert("C++program");
string bookName;
cout<<"电脑前的这位大狭,请输入您在未来六个月想读的书"<<endl;
while(cin>>bookName)
{
if(!readSet.count(bookName))
{
bookVec.push_back(bookName);
readSet.insert(bookName);
}
else
cout<<"这本书您已经读过了"<<endl;
}
cout<<"六个月后......"<<endl;
vector<string>::iterator iter = bookVec.begin();
while(iter != bookVec.end())
{
cout<<*iter<<" "<<"这本书您读了吗,如果读了请输入Y,如果没有请输入N :";
char ch;
cin>>ch;
if(ch == 'N')
readSet.erase(*iter);
else
;
iter++;
}
cout<<"经过您的确认,您这六个月读的书有"<<bookVec.size()<<"本,分别是:"<<endl;
set<string>::const_iterator set_it = readSet.begin();
while(set_it != readSet.end())
{
cout<<*set_it<<endl;
set_it++;
}
cout<<"您没有读的书有:"<<endl;
iter = bookVec.begin();
while(iter != bookVec.end())
{
if(!readSet.count(*iter))
cout<<*iter;
else
;
iter++;
}
cout<<"程序操作完毕"<<endl;
}
int main()
{
readBook();
system("pause");
return 0;
}
不知道怎么写注释
作者: Iしovのyou    时间: 2009-11-3 02:47
问输入什么能够使while(cin>>bookName)中的逻辑值为false?
作者: 芯頽廢.。﹖    时间: 2009-11-3 02:47
ctrl+Z
作者: 苍穹    时间: 2009-11-3 02:47
ctrl+z




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2