-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_analyzer.cpp
81 lines (76 loc) · 1.75 KB
/
data_analyzer.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
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
#define N 100005
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int TESTS=1;
freopen("changes.txt", "r", stdin);
freopen("output.txt", "w", stdout);
while(TESTS--)
{
string s;
int c=0,success=0,flg=0;
map<pair<string,string>,int >m,ms;
while(cin>>s){
if(s=="Failed"){
c++;
flg=1;
cin>>s;
}
else if(s=="Accepted"){
success++;
flg=2;
cin>>s;
}
else if(flg==1){
if(s=="for"){
cin>>s;
cout<<"**after for**"<<s<<"\n";
}
string user=s;
cout<<"user: "<<user<<'\n';
if(user=="invalid"){
cin>>s;
user=user+" "+s;
cin>>s;
user=user+" "+s;
}
cout<<"********************************user****************:"<<user<<'\n';
cin>>s;
cin>>s;
cout<<"pushed into: "<<s<<'\n';
m[{s,user}]++;
flg=0;
}
else if(flg==2){
if(s=="for"){
cin>>s;
cout<<"**after for**"<<s<<"\n";
}
string user=s;
cout<<"user: "<<user<<'\n';
cin>>s;
cin>>s;
cout<<"pushed into: "<<s<<'\n';
ms[{s,user}]++;
flg=0;
}
}
cout<<"\nTotal number of Succesful login : "<<success<< " !!!\n";
cout<<setw(13)<<"Ip address"<<setw(30)<<"Username"<<setw(60)<<"No of times session made \n";
for(auto i:ms){
cout<<setw(13)<<i.F.F<<setw(30)<<i.F.S<<setw(48)<<i.S<<'\n';
}
cout<<"\n\nTotal number of failed attempts made: "<<c<< " !!!\n";
cout<<setw(13)<<"Ip address"<<setw(30)<<"Username"<<setw(60)<<"No of hacking attempts made\n";
for(auto i:m){
cout<<setw(13)<<i.F.F<<setw(30)<<i.F.S<<setw(48)<<i.S<<'\n';
}
}
return 0;
}