TOPIC

100% errado

mmarcelino0 asked 2 years ago

#include <iostream>

using namespace std;

int main()
{
    int c, a;
    int maior;

    while(cin >> c)
    {
      cin >> maior;
      for(int i = 1; i < c; i++){
          cin >> a;
          if (maior < a) {maior = a;}
      }
      if (a < 10) {cout << 1 << endl;} else {
          if (a >= 10 && a < 20) {cout << 2 << endl;} else {cout << 3 << endl;}
      }
    }

    return 0;
}

Qual o meu erro?

Remember not post solutions. Your post may be reviewed by our moderators.

  • feodorv replied 2 years ago

          if (a < 10) {cout << 1 << endl;} else {
              if (a >= 10 && a < 20) {cout << 2 << endl;} else {cout << 3 << endl;}

    Seems you mean

          if (maior < 10) {cout << 1 << endl;} else {
              if (maior >= 10 && maior < 20) {cout << 2 << endl;} else {cout << 3 << endl;}