fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 100;
  5. const int TEN = 10;
  6.  
  7. int isPrime(int digit) {
  8. if (digit == 2 || digit == 3 || digit == 5 || digit == 7) {
  9. return 1;
  10. }
  11. return 0;
  12. }
  13.  
  14. int countPrimeDigits(int num) {
  15. int totalPrimeDigits = 0;
  16. while (num) {
  17. totalPrimeDigits += isPrime(num % TEN);
  18. num /= TEN;
  19. }
  20. return totalPrimeDigits;
  21. }
  22.  
  23. int main() {
  24. int n, lowestErrorPos = 0, maxPrimeDigits = 0;
  25. cin >> n;
  26. for (int i = 1; i <= n; ++i) {
  27. int num;
  28. cin >> num;
  29. if (maxPrimeDigits < countPrimeDigits(num)) {
  30. maxPrimeDigits = countPrimeDigits(num);
  31. lowestErrorPos = i;
  32. }
  33. }
  34.  
  35. if (lowestErrorPos) {
  36. cout << lowestErrorPos;
  37. } else {
  38. cout << "AJUNGE LA DESTINATIE!";
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0s 5276KB
stdin
25 98
stdout
AJUNGE LA DESTINATIE!