fork download
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstdlib>
  4. #include<cmath>
  5. #include<vector>
  6. #include<string>
  7. #include<algorithm>
  8. #include<utility>
  9. #include<set>
  10. #include<queue>
  11.  
  12. using namespace std;
  13.  
  14. int NUM = 10;
  15.  
  16. void printArray(int* a,int n){
  17.  
  18. printf("%d",a[0]);
  19. for(int i=1;i<n;i++){
  20. printf(" %d",a[i]);
  21. }
  22. printf("\n");
  23.  
  24. return;
  25. }
  26.  
  27. int main(){
  28. int a[NUM];
  29.  
  30. for(int i=0;i<NUM;i++){
  31. a[i] = rand();
  32. }
  33.  
  34. printArray(a,NUM);
  35.  
  36. bool isSorted;
  37. do{
  38. random_shuffle(a,a+NUM);
  39.  
  40. isSorted = true;
  41. for(int i=0;i<NUM-1;i++){
  42. if(a[i] > a[i+1]){
  43. isSorted = false;
  44. break;
  45. }
  46. }
  47.  
  48. }while(!isSorted);
  49.  
  50. printArray(a,NUM);
  51.  
  52.  
  53. return 0;
  54. }
  55.  
Success #stdin #stdout 1.26s 2724KB
stdin
Standard input is empty
stdout
1804289383 846930886 1681692777 1714636915 1957747793 424238335 719885386 1649760492 596516649 1189641421
424238335 596516649 719885386 846930886 1189641421 1649760492 1681692777 1714636915 1804289383 1957747793