How to write a C++ program in a short way

50 pts.
Tags:
C
#include<iostream>,#include<fstream>,#include<vector>,#include<string>,#include<algorithm> using namespace std; int main()
{
vector<vector >Container1;// prototype of the functions (Declaring functions)
vectorContainer2;//memory with no limit it holds a dictionary
string data;//memory for words
ifstream read("Inpurt.txt");//opens the file named sua.txt from the read me file.
ofstream out("store.txt");
if(!read)//reading file is not found
{
cout<<"No file";
out<<"No file";
}
else
{
while(!read.eof())
{
vectortemp;//declaring temporary container named temp
read>>data;//where the program read file/data
while(read>>data && data!="%")//direct reading of documents with specified delimiter as the sign of an end of a document
{
for(int i=0;i<data.size();i++) loop="" for="" reading="" each="" document="" {="" data[i]="tolower(data[i]);//convet" the="" string="" to="" lowercase="" character="" }="" temp.push_back(data);="" storing="" strings="" into="" temporary="" container="" named="" temp="" container2.push_back(data);="" if(!temp.empty())="" container1.push_back(temp);="" store="" all="" documents="" cout<<"nn="" unsorted="" listnn"<<endl;="" out<<"nn="" for(int="" i="0;i<Container2.size();i++)" cout<<container2[i]<<endl;="" displays="" terms="" in="" row="" matrix="" out<<container2[i]<<endl;="" sort(container2.begin(),container2.end());="" sort="" from="" begining="" end.="" container2.erase(unique(container2.begin(),container2.end()),container2.end());="" erase="" repeated="" terms.="" sorted="" matrixout<<container2[i]<<endl;="" cout<<"nnthe="" incidece="" matrixnn"<<endl;="" j="0;j<Container1.size();j++)//find" if="" a="" term="" occcur="" is="" cout<<="" "tt="" d"<<j+1;="" out<<="" "t="" cout<<endl;="" out<<endl;="" cout<<"n"<<container2[i]<<endl;="" out<<"n"<<container2[i]<<endl;="" vector::const_iterator//provide iteration access to the vector terms.
K=find(Container1[j].begin(),Container1[j].end(),Container2[i]);//for finding document
if(K!=Container1[j].end())//if the document is not presesnt
{

cout<<"tt 1";//display ones.
out<<"t 1";
}
else{
cout<<"tt 0";//return 0 if term does not occur in the document
out<<"t 0";

}}
cout<<endl; out<<endl;="" }="" return="" 0;="" the="" end="" of="" program="" a="" for="" term="" document="" created="" on="" 15="" 04="" 2015="" #include="" // basic standard input-outputput library in c++ program
#include // file handling
#include // act container for storing data
#include // for reading those characters or names
#include // for data sorting
using namespace std;//allows you to use the standard space
int main()//The main function where a c++ program execution start.
{
vector<vector >Container1;// prototype of the functions (Declaring functions)
vectorContainer2;//memory with no limit it holds a dictionary
string data;//memory for words
ifstream read("Inpurt.txt");//opens the file named sua.txt from the read me file.
ofstream out("store.txt");
if(!read)//reading file is not found
{
cout<<"No file";
out<<"No file";
}
else
{
while(!read.eof())
{
vectortemp;//declaring temporary container named temp
read>>data;//where the program read file/data
while(read>>data && data!="%")//direct reading of documents with specified delimiter as the sign of an end of a document
{
for(int i=0;i<data.size();i++) loop="" for="" reading="" each="" document="" {="" data[i]="tolower(data[i]);//convet" the="" string="" to="" lowercase="" character="" }="" temp.push_back(data);="" storing="" strings="" into="" temporary="" container="" named="" temp="" container2.push_back(data);="" if(!temp.empty())="" container1.push_back(temp);="" store="" all="" documents="" cout<<"nn="" unsorted="" listnn"<<endl;="" out<<"nn="" for(int="" i="0;i<Container2.size();i++)" cout<<container2[i]<<endl;="" displays="" terms="" in="" row="" matrix="" out<<container2[i]<<endl;="" sort(container2.begin(),container2.end());="" sort="" from="" begining="" end.="" container2.erase(unique(container2.begin(),container2.end()),container2.end());="" erase="" repeated="" terms.="" sorted="" matrixout<<container2[i]<<endl;="" cout<<"nnthe="" incidece="" matrixnn"<<endl;="" j="0;j<Container1.size();j++)//find" if="" a="" term="" occcur="" is="" cout<<="" "tt="" d"<<j+1;="" out<<="" "t="" cout<<endl;="" out<<endl;="" cout<<"n"<<container2[i]<<endl;="" out<<"n"<<container2[i]<<endl;="" vector::const_iterator//provide iteration access to the vector terms.
K=find(Container1[j].begin(),Container1[j].end(),Container2[i]);//for finding document
if(K!=Container1[j].end())//if the document is not present
{

cout<<"tt 1";//display ones.
out<<"t 1";
}
else{
cout<<"tt 0";//return 0 if term does not occur in the document
out<<"t 0";

}}
cout<<endl; out<<endl;="" }="" return="" 0;="" the="" end="" of="" program="" a="" for="" term="" document="" created="" on="" 15="" 04="" 2015="" #include="" // basic standard input-outputput library in c++ program
#include // file handling
#include // act container for storing data
#include // for reading those characters or names
#include // for data sorting
using namespace std;//allows you to use the standard space
int main()//The main function where a c++ program execution start.
{
vector<vector >Container1;// prototype of the functions (Declaring functions)
vectorContainer2;//memory with no limit it holds a dictionary
string data;//memory for words
ifstream read("Inpurt.txt");//opens the file named sua.txt from the read me file.
ofstream out("store.txt");
if(!read)//reading file is not found
{
cout<<"No file";
out<<"No file";
}
else
{
while(!read.eof())
{
vectortemp;//declaring temporary container named temp
read>>data;//where the program read file/data
while(read>>data && data!="%")//direct reading of documents with specified delimiter as the sign of an end of a document
{
for(int i=0;i<data.size();i++) loop="" for="" reading="" each="" document="" {="" data[i]="tolower(data[i]);//convet" the="" string="" to="" lowercase="" character="" }="" temp.push_back(data);="" storing="" strings="" into="" temporary="" container="" named="" temp="" container2.push_back(data);="" if(!temp.empty())="" container1.push_back(temp);="" store="" all="" documents="" cout<<"nn="" unsorted="" listnn"<<endl;="" out<<"nn="" for(int="" i="0;i<Container2.size();i++)" cout<<container2[i]<<endl;="" displays="" terms="" in="" row="" matrix="" out<<container2[i]<<endl;="" sort(container2.begin(),container2.end());="" sort="" from="" begining="" end.="" container2.erase(unique(container2.begin(),container2.end()),container2.end());="" erase="" repeated="" terms.="" sorted="" matrixout<<container2[i]<<endl;="" cout<<"nnthe="" incidece="" matrixnn"<<endl;="" j="0;j<Container1.size();j++)//find" if="" a="" term="" occcur="" is="" cout<<="" "tt="" d"<<j+1;="" out<<="" "t="" cout<<endl;="" out<<endl;="" cout<<"n"<<container2[i]<<endl;="" out<<"n"<<container2[i]<<endl;="" vector::const_iterator//provide iteration access to the vector terms.
K=find(Container1[j].begin(),Container1[j].end(),Container2[i]);//for finding document
if(K!=Container1[j].end())//if the document is not presesnt
{

cout<<"tt 1";//display ones.
out<<"t 1";
}
else{
cout<<"tt 0";//return 0 if term does not occur in the document
out<<"t 0";

}}
cout<<endl; out<<endl;="" }="" return="" 0;="" the="" end="" of="" program="" a="" for="" term="" document="" created="" on="" 15="" 04="" 2015="" #include="" // basic standard input-outputput library in c++ program
#include // file handling
#include // act container for storing data
#include // for reading those characters or names
#include // for data sorting
using namespace std;//allows you to use the standard space
int main()//The main function where a c++ program execution start.
{
vector<vector >Container1;// prototype of the functions (Declaring functions)
vectorContainer2;//memory with no limit it holds a dictionary
string data;//memory for words
ifstream read("Inpurt.txt");//opens the file named sua.txt from the read me file.
ofstream out("store.txt");
if(!read)//reading file is not found
{
cout<<"No file";
out<<"No file";
}
else
{
while(!read.eof())
{
vectortemp;//declaring temporary container named temp
read>>data;//where the program read file/data
while(read>>data && data!="%")//direct reading of documents with specified delimiter as the sign of an end of a document
{
for(int i=0;i<data.size();i++) loop="" for="" reading="" each="" document="" {="" data[i]="tolower(data[i]);//convet" the="" string="" to="" lowercase="" character="" }="" temp.push_back(data);="" storing="" strings="" into="" temporary="" container="" named="" temp="" container2.push_back(data);="" if(!temp.empty())="" container1.push_back(temp);="" store="" all="" documents="" cout<<"nn="" unsorted="" listnn"<<endl;="" out<<"nn="" for(int="" i="0;i<Container2.size();i++)" cout<<container2[i]<<endl;="" displays="" terms="" in="" row="" matrix="" out<<container2[i]<<endl;="" sort(container2.begin(),container2.end());="" sort="" from="" begining="" end.="" container2.erase(unique(container2.begin(),container2.end()),container2.end());="" erase="" repeated="" terms.="" sorted="" matrixout<<container2[i]<<endl;="" cout<<"nnthe="" incidece="" matrixnn"<<endl;="" j="0;j<Container1.size();j++)//find" if="" a="" term="" occcur="" is="" cout<<="" "tt="" d"<<j+1;="" out<<="" "t="" cout<<endl;="" out<<endl;="" cout<<"n"<<container2[i]<<endl;="" out<<"n"<<container2[i]<<endl;="" vector::const_iterator//provide iteration access to the vector terms.
K=find(Container1[j].begin(),Container1[j].end(),Container2[i]);//for finding document
if(K!=Container1[j].end())//if the document is not presesnt
{

cout<<"tt 1";//display ones.
out<<"t 1";
}
else{
cout<<"tt 0";//return 0 if term does not occur in the document
out<<"t 0";

}}
cout<</vector</vector</vector</vector
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • chiku1410
    how to write the program above in a short way.The program is about to display term document matrix.
    50 pointsBadges:
    report
  • ToddN2000
    What do you mean by "short way", a smaller piece of code?
    133,645 pointsBadges:
    report
  • chiku1410
    Yes, a smaller piece of code to display term document using C++.
    50 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: