例
让我们看下面的实现以更好地理解-
#include <bits/stdc++.h> using namespace std; class Solution { public: bool checkPerfectNumber(int num) { set<int> set={6,28,496,8128,33550336}; return set.find(num)!=set.end(); } }; main(){ Solution ob; cout << (ob.checkPerfectNumber(28)); }
28
输出结果
1