#include <stdio.h>
#include <locale.h>
struct musica {
char nome[ 100 ] ;
char estilo[ 100 ] ;
int rank;
} ;
typedef struct musica Musica;
int main ( void ) {
int i, j, aux;
Musica a[ 8 ] ;
for ( i= 0 ; i< 4 ; i++ ) {
printf ( "Ranking da música: " ) ;
}
//RANKING DIGITADO DESORDENADO
for ( i= 0 ; i< 4 ; i++ ) {
printf ( "RANK %d\t %s\t %s\t \n " , a
[ i
] .
rank , a
[ i
] .
nome , a
[ i
] .
estilo ) ; }
Musica temp;
for ( i= 0 ; i< 4 ; i++ ) {
for ( j= i+ 1 ; j< 4 ; j++ ) {
if ( a[ i] .rank > a[ j] .rank ) {
temp = a[ i] ;
a[ i] = a[ j] ;
a[ j] = temp;
}
}
}
//RANKING ORDEM
for ( i= 0 ; i< 4 ; i++ ) {
printf ( "RANK %d\t %s\t %s\t \n " , a
[ i
] .
rank , a
[ i
] .
nome , a
[ i
] .
estilo ) ; }
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxsb2NhbGUuaD4KCnN0cnVjdCBtdXNpY2EgewoJY2hhciBub21lWzEwMF07CgljaGFyIGVzdGlsb1sxMDBdOwoJaW50IHJhbms7Cn07Cgp0eXBlZGVmIHN0cnVjdCBtdXNpY2EgTXVzaWNhOwoKaW50IG1haW4gKHZvaWQpIHsKCWludCBpLGosYXV4OwoJTXVzaWNhIGFbOF07CgkKCglzZXRsb2NhbGUoTENfQUxMLCAiUG9ydHVndWVzZSIpOwoKCWZvciAoaT0wOyBpPDQ7IGkrKykgewoKCQlwcmludGYgKCJOb21lIGRhIG3DunNpY2E6ICIpOwoJCWdldHMgKGFbaV0ubm9tZSk7CgoJCXByaW50ZiAoIkVzdGlsbyBtdXNpY2FsOiAiKTsKCQlnZXRzIChhW2ldLmVzdGlsbyk7CgoJCXByaW50ZiAoIlJhbmtpbmcgZGEgbcO6c2ljYTogIik7CgkJc2NhbmYgKCIlZCIsJmFbaV0ucmFuayk7CgoJCXByaW50ZiAoI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