// ConsoleApplication25.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
#include <vector>
#include <algorithm>
using namespace System;
using namespace std;
int main()
{
vector<string> words;
string x;
cout << "Enter words followed by end of file: " << endl;
while (cin >> x){
words.push_back(x);
}
cout << endl;
int count=0;
string Uword;
cout << "Enter the word you want me to count" << endl;
cin >> Uword;
for(int i = 0; i < (int)words.size(); ++i){
if (Uword == words[i]){
++count;
}
cout << "You word appeared " << count << " times" << endl;
system("pause");
return 0;
}
可有一个人告诉我,我做错了什么工作? :/显然我不明白一个关键概念。该程序不断跳过我的第二个cin
。甚至没有看到for循环,我也不知道为什么。