HELP- What is the function of "!!" in C++?

Правка en1, от aman_012, 2020-04-19 08:36:20

Hello,

I was going through one of[user:tourist]'s submissions and i came across this small piece of code and i am really curious to know what it does. Whole code:

/** * author: tourist * created: 13.04.2020 17:37:41
**/

include <bits/stdc++.h>

using namespace std;

int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { int n; cin >> n; vector cnt(n); for (int i = 0; i < n; i++) { int x; cin >> x; --x; ++cnt[x]; } int mx = *max_element(cnt.begin(), cnt.end()); int cc = 0; for (int i = 0; i < n; i++) { cc += !!cnt[i]; ///////////////////////////////////////RIGHT HERE////////////////////////////// } cout << min(mx, cc) — (mx == cc) << '\n'; } return 0; }

Thanks in advance!

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский aman_012 2020-04-19 08:39:10 14 Tiny change: 'ugh one of[user:tourist]'s submissio' -> 'ugh one of [user:tourist] submissio'
en2 Английский aman_012 2020-04-19 08:38:36 671
en1 Английский aman_012 2020-04-19 08:36:20 933 Initial revision (published)