好的,所以我在做一个家庭作业,我假设读取一个包含 100 个选定单词的文本文件,然后读取另一个“文本”文件并比较这 100 个选定单词中有多少出现在“文本”文件上,什么是最长的和最短的单词以及这些选定单词在文本文件中出现的次数。我需要完整的帮助,这是我到目前为止所得到的。顺便说一句,我还没有输入选定的文件,所以这就是为什么那些 ifs 语句不完整
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
int fileNumber;
string Words [100];
string wordCounts [100];
string Frequencies [100];
string shortest = "abcdefghijklmnopqrstuvwxyz";
string longest = "";
int totalWordCount = 0;
ifstream inData;
int I=0;
inData.open("SelectWords.txt");
while ( !inData.eof () ) {
inData >> Words [I];
}
int irow;
while ( irow=0, irow<=100, irow++) {
cout<<Words[I]<<endl;
}
cout<<"Choose a file you want to open"<<endl;
cout<<"1= A Modest Proposal"<<endl;
cout<<"2=Apology" <<endl;
cout<<"3=The Call of the Wild"<<endl;
cout<<"4=The Adventures of Tom Sawyer"<<endl;
cin>> fileNumber;
while ((fileNumber<1) || (fileNumber>4))
{
cout<<"Error please try again"<<endl;
cout<<"Choose a file you want to open"<<endl;
cout<<"1 - A Modest Proposal"<<endl;
cout<<"2 - Apology" <<endl;
cout<<"3 - The Call of the Wild"<<endl;
cout<<"4 - The Adventures of Tom Sawyer"<<endl;
cin>> fileNumber;
}
if (fileNumber==1)
{
}
if (fileNumber==2)
{
}
if (fileNumber==3)
{
}
if (fileNumber==4)
{
}
system ("pause");
return 0;
}