fork download
  1. #include<iostream>
  2. #include<stdlib.h>
  3. using namespace std;
  4.  
  5. int main(int argc, char const *argv[])
  6. {
  7. int n, temp;
  8. cout<<"Donnez la taille";
  9. cin>>n;
  10. int *t;
  11. t=(int*)malloc(sizeof(int)*n);
  12. for (int i = 0; i < n; ++i)
  13. {
  14. cout<<"Donnez une case";
  15. cin>>t[i];
  16. }
  17.  
  18. for (int i = 0; i < n; ++i)
  19. {
  20. for (int j = i; j < n; ++j)
  21. {
  22. if(t[i]>t[j]){
  23. temp=t[i];
  24. t[i]=t[j];
  25. t[j]=temp;
  26. }
  27. }
  28. }
  29.  
  30. for (int i = 0; i < n; ++i)
  31. {
  32. cout<<t[i]<<"\t";
  33. }
  34. free(t);
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5320KB
stdin
5
1
1
2
1
2
stdout
Donnez la tailleDonnez une caseDonnez une caseDonnez une caseDonnez une caseDonnez une case1	1	1	2	2