Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. char mas[] = { 8, 7, 3, 9, 5, 2};
  2.  
  3. void max3(int * a, int N)
  4. {
  5. int i, retry;
  6. for(i = 0; i < N-3; ++i)
  7. {
  8. for(retry = 1; retry;)
  9. {
  10. retry = 0;
  11. for(int j = N-1; j >= N-3; --j)
  12. {
  13. if (a[i] > a[j])
  14. {
  15. int tmp = a[i];
  16. a[i] = a[j];
  17. a[j] = tmp;
  18. retry = 1;
  19. break;
  20. }
  21. }
  22. }
  23. }
  24. }
  25.  
  26.  
  27. int main(int argc, const char * argv[])
  28. {
  29. int a[] = { 3, 5, 7, 1, 9, 2, 8, 0, 1, 9 };
  30. max3(a,sizeof(a)/sizeof(a[0]));
  31. for(int j = sizeof(a)/sizeof(a[0])-3; j < sizeof(a)/sizeof(a[0]); ++j)
  32. {
  33. printf("%3d",a[j]);
  34. }
  35. printf("n");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement