jonny_696_ Posted December 11, 2007 at 11:34 AM Report Share #153615 Posted December 11, 2007 at 11:34 AM #include <stdio.h> #include <conio.h> main() { int notas[10], i,j,c; /* pd nº po array */ for (i=0;i<10;i++) { printf("Nota do aluno n. %d: ",i+1); scanf("%d",¬as[i]); } /* --- --- */ /* ordena-os decrescent */ for (i=0;i<10;i++) { for (j=0;j<10;j++) { if (notas[i]>notas[j]) { c=notas[j]; notas[j]=notas[i]; notas[i]=c; } } } /* --- --- */ /* escreve-os */ for (i=0;i<10;i++) { printf("ord: %d\n",notas[i]); } /* --- --- */ getch(); } --deixem coments-- Link to comment Share on other sites More sharing options...
jonny_696_ Posted December 11, 2007 at 11:37 AM Author Report Share #153616 Posted December 11, 2007 at 11:37 AM /* ordena-os crescent */ for (i=0;i<10;i++) { for (j=0;j<10;j++) { if (notas[i]<notas[j]) { c=notas[j]; notas[j]=notas[i]; notas[i]=c; } } } /* --- --- */ se kiserem crescent basta mudar o simbolo de ">" para "<" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now