fork download
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. bool comp(int l, int r)
  8. {
  9. if (l%2 < r%2) return true;
  10. if (l%2 > r%2) return false;
  11. if (l%2 == 0 && r%2 == 0)
  12. return l < r;
  13. if (l%2 == 1 && r%2 == 1)
  14. return l > r;
  15. return false;
  16. }
  17.  
  18. int main(int argc, const char * argv[])
  19. {
  20. vector<int> v;
  21. for(int i = 0; i < 400 ; ++i)
  22. {
  23. v.push_back(rand()%10000);
  24. }
  25.  
  26. sort(v.begin(),v.end(),comp);
  27.  
  28.  
  29. for(auto i: v) cout << i << " "; cout << endl;
  30. }
  31.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
12 84 124 280 336 364 378 492 492 524 540 570 688 756 846 868 886 1222 1326 1340 1396 1432 1434 1474 1500 1528 1530 1776 1860 1936 1972 2036 2062 2090 2172 2298 2336 2350 2362 2404 2422 2504 2590 2600 2618 2754 2754 2842 2846 2862 2902 2904 2924 2926 2954 2996 3058 3202 3258 3324 3348 3368 3368 3376 3416 3426 3452 3506 3526 3584 3622 3730 3750 3784 3810 3850 3898 3920 3926 3940 4022 4286 4324 4340 4370 4428 4538 4586 4818 4878 4914 4930 5060 5084 5128 5198 5210 5306 5368 5386 5422 5434 5542 5550 5568 5590 5624 5630 5644 5732 5736 5746 5782 5788 5818 5856 5884 5894 5928 5936 5984 5994 6042 6124 6190 6226 6228 6340 6342 6348 6466 6640 6652 6658 6708 6784 6808 6840 6862 6996 6996 7034 7084 7178 7190 7276 7372 7468 7488 7672 7684 7732 7764 7764 7796 7828 7856 8004 8042 8082 8094 8142 8202 8206 8228 8270 8282 8418 8440 8444 8456 8464 8490 8522 8542 8586 8606 8624 8626 8660 8690 8736 8776 8804 8814 8850 8858 8944 8980 9150 9170 9172 9224 9228 9292 9320 9336 9412 9444 9470 9582 9668 9676 9708 9756 9772 9786 9802 9904 9932 9956 9917 9859 9841 9811 9689 9567 9529 9507 9503 9497 9441 9383 9379 9355 9301 9299 9299 9179 9107 8933 8927 8899 8829 8819 8611 8581 8537 8365 8335 8315 8235 8209 8167 8149 8139 8117 8097 8031 7981 7917 7793 7763 7743 7739 7721 7713 7669 7637 7625 7621 7605 7587 7539 7505 7467 7445 7373 7369 7343 7301 7281 7269 7255 7199 7131 6987 6965 6915 6887 6725 6715 6649 6619 6601 6505 6491 6437 6429 6413 6327 6229 6219 6143 6121 6091 6029 5939 5857 5771 5763 5667 5661 5579 5499 5407 5403 5385 5321 5273 5211 5193 5123 5011 4919 4819 4769 4729 4683 4613 4599 4567 4481 4443 4421 4395 4259 4081 4067 4043 3929 3895 3881 3865 3793 3773 3743 3555 3465 3451 3367 3317 3311 3275 3205 3135 3069 2959 2921 2871 2813 2777 2651 2567 2551 2399 2379 2353 2305 2245 2227 2183 2021 2009 1993 1961 1899 1873 1801 1729 1705 1659 1421 1393 1313 1305 1255 1237 1155 1127 1095 1087 1011 973 925 795 723 713 709 675 613 545 379 197 163 97 71 59 27 19