fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int a[10];
  5. for (int i = 0; i < 10; i++) {
  6. printf("Entre com os numeros %d: ", i);
  7. scanf("%d", &a[i]);
  8. }
  9. for (int i = 0; i < 10; i++) {
  10. for (int x = i + 1; x < 10; x++) {
  11. if (a[i] > a[x]) {
  12. int aux = a[i];
  13. a[i] = a[x];
  14. a[x] = aux;
  15. }
  16. }
  17. }
  18. printf ("Lista dos elementos em ordem a seguir:\n");
  19. for (int i = 0; i < 10; i++) printf("%d\n", a[i]);
  20. }
  21.  
  22. //https://pt.stackoverflow.com/q/359966/101
Success #stdin #stdout 0s 9424KB
stdin
5
2
8
1
4
9
2
3
8
6
stdout
Entre com os numeros 0: Entre com os numeros 1: Entre com os numeros 2: Entre com os numeros 3: Entre com os numeros 4: Entre com os numeros 5: Entre com os numeros 6: Entre com os numeros 7: Entre com os numeros 8: Entre com os numeros 9: Lista dos elementos em ordem a seguir:
1
2
2
3
4
5
6
8
8
9