TOPIC

Resultados batem, porém há sempre o erro de 100%.

Jonathan Fernandes asked 1 year ago

using System; 

class URI {

    static void Main(string[] args) { 

 string[] s;
            int ocorrencias;
            double somatorio = 0;
            int cont = 0;
            double porcent;

            ocorrencias = Convert.ToInt32(Console.ReadLine());
            for (int j = 0; j < ocorrencias; j++)
            {
              s = Console.ReadLine().Split(' ');

            int NumNotas = Convert.ToInt32(s[0]);

                for (int i = 1; i < NumNotas + 1; i++)
                {
                    somatorio += Convert.ToInt32(s[i]);
                }

            double media = somatorio / NumNotas;

                for (int i = 1; i < NumNotas + 1; i++)
                {
                    if (Convert.ToInt32(s[i]) >  media )
                    {
                        cont++;
                    }

                }
                porcent = ((100.0 * cont) / NumNotas);
                cont = 0;
                somatorio = 0;

                Console.WriteLine((porcent/100).ToString("0.000%").Replace(',','.'));
            }

    }

}``

This topic has not been answered yet. Be the first!

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