fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 100;
  5. const int TEN = 10;
  6.  
  7. bool hasSixDigits(int n) {
  8. int numDigits = 0;
  9. while (n) {
  10. ++numDigits;
  11. n /= TEN;
  12. }
  13. return numDigits == 6;
  14. }
  15.  
  16. bool isDistinct(int currentNum, int numbersRead[], int currentPos) {
  17. for (int i = currentPos - 1; i >= 0; --i) {
  18. if (currentNum == numbersRead[i]) {
  19. return false;
  20. }
  21. }
  22. return true;
  23. }
  24.  
  25. int main() {
  26. int numbersRead[MAX_SIZE], n;
  27. cin >> n;
  28. int totalSum = 0, validNumbs = 0;
  29. for (int i = 0; i < n; ++i) {
  30. cin >> numbersRead[i];
  31. if (isDistinct(numbersRead[i], numbersRead, i)) {
  32. totalSum += numbersRead[i];
  33. validNumbs += hasSixDigits(numbersRead[i]);
  34. }
  35. }
  36. if (validNumbs < 2) {
  37. cout << "EROARE";
  38. } else {
  39. cout << totalSum;
  40. }
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0.01s 5280KB
stdin
3
392833 23 193
stdout
EROARE