Reginaldojs

exercicio 9,lista 4

Jun 22nd, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3. int main() {
  4.    int n[] = {9,7,3,1};
  5.    int i, aux, mud;
  6.    mud = 1;
  7.    while(mud == 1) {
  8.        mud= 0;
  9.        i=0;
  10.        while(i<=sizeof(n)/sizeof(int)-2) {
  11.            if(n[i] > n[i+1]) {
  12.               aux = n[i];
  13.               n[i] = n[i+1];
  14.               n[i+1] = aux;
  15.               mud= 1;
  16.            }
  17.            i++;
  18.        }
  19.    }
  20.    for(i=0; i<=3; i++) {
  21.       printf("%d\n", n[i]);
  22.    }
  23.    system ("pause");
  24.    return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment