fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int data[] = {7,7,7,7,7,7,42,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
  8. size_t N = sizeof(data)/sizeof(data[0]);
  9. sort(data, data+3);
  10. int non_unique = data[1];
  11. for (int i = 0 ; i != N ; i++) {
  12. if (data[i] != non_unique) {
  13. cout << data[i] << endl;
  14. break;
  15. }
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0.02s 2680KB
stdin
Standard input is empty
stdout
42