-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre.cpp
More file actions
70 lines (69 loc) · 1.05 KB
/
pre.cpp
File metadata and controls
70 lines (69 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<sstream>
#include<string.h>
using namespace std;
int main()
{
vector<string> list;
ifstream word("words.txt");
while(word)
{
string s;
word>>s;
list.push_back(s);
}
ofstream x("xftest.txt");
ofstream y("ytest.txt");
ifstream data("testtry.txt");
char line[50000];
int i=0;
while(data)
{
data.getline(line,50000,'\n');
istringstream iss(line);
cout<<(++i)<<endl;
vector<int> v(list.size());
for(int i=0;i<v.size();i++)
{
v[i]=0;
}
string label;
iss>>label;
if(label == "rec.autos")
{
y<<1<<endl;
}
else if(label == "rec.motorcycles")
{
y<<2<<endl;
}
else if (label == "rec.sport.baseball")
y<<3<<endl;
else if (label == "rec.sport.hockey")
y<<4<<endl;
string s;
while(iss)
{
iss>>s;
for(int i=0;i<list.size();i++)
{
if(list[i]==s)
{
v[i]++;
break;
}
}
}
//cout<<v.size()<<endl;
for(int i=0;i<v.size();i++)
{
//x<<i<<" ";
x<<v[i]<<" ";
}
//cout<<endl;
x<<"\n";
}
}