编写程序,从键盘读入一个文本文件名字(可带路径),为该文件中的所有单词建立一

来源:百度知道 编辑:UC知道 时间:2024/07/04 12:51:27
编写程序,从键盘读入一个文本文件名字(可带路径),为该文件中的所有单词建立一个词汇索引。按字母顺序显示所有单词(仅一次),后面紧跟着它们所在的行号。大写与小写字母被认为是相同的。例如,对于下列的输入文件:

To be or
not to be,
that is the question.
产生的词汇索引如下:
be 1 2
is 3
not 2
or 1
question 3
that 3
the 3
to 1 2
最晚明17号晚上不然就没用了

写好了

#pragma warning(disable:4786)
#include<fstream>
#include<string>
#include<iostream>
#include <iomanip>
#include<vector>
#include <set>
#include <cctype>
//by wangtk1982
using namespace std;
struct WORDS
{
string str;
int line;
}words;
int main()
{
vector<WORDS>data;
set<string>tsdata;
string sFilePath,sline;
cin>>sFilePath;
int lines=0;
ifstream file(sFilePath.c_str());
if(!file)
{
cerr<<"Cann't open file:"<<sFilePath<<endl;
return 0;
} ;
while(getline(file,sline,'\n'))
{
for(int i=0;i <sline.size();++i)
sline[i]=isalnum(sline[i])?sline[i]:' ';
lines++;
char *p = strtok ((char*)sline.c_str()," ");
while

编写程序,从键盘读入一个符号,如果它ASII值是偶数则输出1 编写一个程序,从键盘读入一系列字符串,然后报告输入的最长以及最短的字符串的长度。 编写程序,从键盘读入一组整数,存于一维数组中,并编写一组自定义函数 编写程序,从键盘读入一个符号,如果他的ASCII值是偶数则输出为0。是奇数输出为1呢? 编写程序,从键盘读入10个整数存入整型数组a中,然后逆序输出这10个整数。 请问用怎样用VB编写一个程序,能从文本文件中读取数据到数组中 编写一个程序,统计一个文本文件的行数(C语言) 用JAVA 编写程序,从键盘读入10个整数存入数组,输出最大值,最小值及它们所在数组中的位置 java中如何从键盘读入一个数 求——从键盘读入一国位二进制数,显示对应的十进制数。汇编语言编写。