Skip to content

Commit da35e9d

Browse files
Word Frequency
1 parent e6b1576 commit da35e9d

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

word_frequency.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <bits/stdc++.h>
2+
3+
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
4+
#define f(i,a,b) for(auto i=a;i<b;i++)
5+
#define fi(i,a,b,x) for(auto i=a;i<b;i=i+x)
6+
#define fe(i,a,b) for(auto i=a;i<=b;i++)
7+
#define fr(i,a,b) for(auto i=a;i>=b;i--)
8+
#define loop(i, a) for(auto i=a.begin();i!=a.end();i++)
9+
#define endl '\n'
10+
#define sp '\t'
11+
#define ll long long int
12+
#define ff first
13+
#define ss second
14+
#define pb push_back
15+
#define mp make_pair
16+
#define all(x) x.begin(), x.end()
17+
#define clr(x) memset(x, 0, sizeof(x))
18+
#define sortall(x) sort(all(x))
19+
#define mod 1000000007
20+
#define PI 3.1415926535897932384626
21+
#define deb(x) cout<<#x<<"="<<x<<endl
22+
#define deb2(x, y) cout<<#x<<" = "<<x<<","<<#y<<" = "<<y<<endl
23+
24+
using namespace std;
25+
26+
template <typename T>
27+
void print(vector<T>& a, char sep)
28+
{
29+
for(auto i : a) { cout<<i<<sep; }
30+
}
31+
32+
ll mod_opr(ll num)
33+
{
34+
return (num + mod) % mod;
35+
}
36+
37+
template <typename T>
38+
bool compare(T x, T y)
39+
{
40+
return x > y ? true : false;
41+
}
42+
43+
int main()
44+
{
45+
fast;
46+
47+
string s;
48+
getline(cin, s);
49+
istringstream iss(s);
50+
unordered_map<string, ll> count;
51+
for(string s; iss>>s; ){
52+
count[s]++;
53+
}
54+
for(auto i : count){
55+
cout<<i.ff<<" "<<i.ss<<endl;
56+
}
57+
58+
return 0;
59+
}

0 commit comments

Comments
 (0)