TOPIC

Apenas 10% de wrong answer

Leandro181 asked 4 years ago

include

include

//exer-1171-uri int main() { int qtdeEnt,j=0,i=0,y=0,cont=1,cont2=0,aux=0,x=0; int num[40001]={0};

printf("Insira a 1 entrada\n");
scanf("%d",&qtdeEnt);
i=0;
x=0;
for( i=0; i<40001; i++)
{   num[i]=0;
    while(x < qtdeEnt)  
    {
        i=x;
        printf("Insira um valor\n");
        scanf("%d",&num[i]);
        if(num[i]<1 || num[i]>2000)
        {
            num[i]=0;
        }
        x++;
        break;
    }
}

for(y=0;  y<qtdeEnt; y++)
{   

    for(j=y+1; j<qtdeEnt; j++)
    {   
        if(num[y]>num[j] || num[y]== num[j] )
        {   

            aux=num[y];
            num[y]=num[j];
            num[j]=aux;
        }

    }

    aux=0;

}

j=0;
y=0;
for( y=0; y<qtdeEnt; y++)
{

    for(j=y+1;j<qtdeEnt+1; j++)
    {
        if(num[y]!=num[j])
        {
            cont=1;
            break;
        }
        else
        {
            cont2++;
            //limit++;
            //j++;
            //cont=0;
        }
        y++;
    }   
    if(num[y]!=0 && cont2<=20)
        printf("\n O %d aparece %d vez(es)\n", num[y],cont+cont2);
    else
        printf("\n");
    cont=0;
    cont2=0;

}

}

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

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