Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int v[5],x,y,z,n;
- x=0;
- printf ("Digite o tamanho do vetor \n");
- scanf ("%d" ,&n);
- printf ("Digite os componentes do vetor \n");
- while (x<n){
- scanf ("%d" ,&v[x]);
- x++;
- }
- x=0;
- z=0;
- while (z<n-1){
- while (x<n-1){
- z=x+1;
- if (v[x]>v[z]){
- y=0;
- y=v[x];
- v[x]=v[z];
- v[z]=y;
- x++;
- }
- }
- z++;
- x=0;
- }
- while (x<n){
- printf ("%d " ,v[x]);
- x++;
- }
- }
Add Comment
Please, Sign In to add comment