What is the bubble short error in this code?

1
  

I tried to solve this problem of Online Judge URI and I got to this   code, and it works for test cases smaller than the problem, and   I already looked for the error, but I can not find it.

  

Code:

#include<stdio.h>#include<stdlib.h>typedefstructpaises{unsignedintouro,prata,bronze;int*v;charnome[50];}classe;intmain(){classe*v;classeord;shortintn,i;scanf("%hd", &n);
    v = (classe *)malloc(n * sizeof(classe));
    for(i=0;i<n;i++){
        fflush(stdin);
        scanf("%s",v[i].nome);
        scanf("%d",&v[i].ouro);
        scanf("%d",&v[i].prata);
        scanf("%d",&v[i].bronze);
    }
        for(i=0;i<n-1;i++){
            if(v[i].ouro>v[i+1].ouro){
                ord=v[i];
                v[i]=v[i+1];
                v[i+1]=ord;
            }

             if(v[i].prata>v[i+1].prata&&v[i].ouro==v[i+1].ouro){
            ord=v[i];
            v[i]=v[i+1];
            v[i+1]=ord;
            }
             if(v[i].bronze>v[i+1].bronze&&v[i].prata==v[i+1].prata&&v[i].ouro==v[i+1].ouro){
            ord=v[i];
            v[i]=v[i+1];
            v[i+1]=ord;
            }


        }

    for(i=n-1;i>=0;i--){
    printf("\n%s %d %d %d\n",v[i].nome,v[i].ouro,v[i].prata,v[i].bronze);
    }
  

Code Output:

    
asked by anonymous 09.04.2018 / 05:06

0 answers