forked from srijanee/DGA
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.cpp
111 lines (100 loc) · 1.53 KB
/
start.cpp
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include<iostream>
#include<fstream>
#include<sstream>
#include<vector>
using namespace std;
int c=0;
void duval(vector<vector<int> > v)
{
ofstream file("datafile.txt");
vector<int> ans;
cout<<v.size()<<endl;
for(int i=0;i<v.size();i++)
{
float p1,p2,p3;
double sum =(v[i][1]+v[i][2]+v[i][4]);
if(sum==0)
{
sum=sum+0.001;
}
if(v[i][1]>120 || v[i][2]>50 || v[i][4]>1)
{
file<<v[i][0]<<" "<<v[i][1]<<" "<<v[i][2]<<" "<<v[i][3]<<" "<<v[i][4]<<endl;
p1=v[i][1]*100/sum;
p2=v[i][2]*100/sum;
p3=v[i][4]*100/sum;
if(p1>=98)
{
ans.push_back(1);
}
else if(p3<4)
{
if(p2>=20 && p2<=50)
{
ans.push_back(5);
}
else if(p2<20)
{
ans.push_back(4);
}
else
{
ans.push_back(8);
}
}
else if(p3<13 && p2<23)
{
ans.push_back(2);
}
else if(p3<15 && p2>=50)
{
ans.push_back(6);
}
else if(p3>=29 && p3<=77 && p2>=23 && p2<=40)
{
ans.push_back(3);
}
else
{
ans.push_back(7);
}
}
else
{
//ans.push_back(-1);
c++;
}
}
cout<<ans.size()<<endl;
cout<<c<<endl;
ofstream a("Output.txt");
for(int i=0;i<ans.size();i++)
{
a<<ans[i]<<endl;
}
}
int main()
{
vector<vector<int> >v;
ifstream file("2.txt");
char line[512];
file.getline(line,512,'\n');
istringstream iss(line);
string a,b,c,d,e;
iss>>a>>b>>c>>d>>e;
int ct=0;
for(ct=1;ct<=26934;ct++)
{
file.getline(line,512,'\n');
istringstream iss(line);
vector<int> p;
for(int i=0;i<5;i++)
{
int x;
iss>>x;
p.push_back(x);
}
v.push_back(p);
}
duval(v);
}