Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void f9(int * a, int n) {
- int flag = 1;
- while (flag) {
- flag = 0;
- int i;
- for (i = n - 2; i >= 0; --i) {
- int sgn1 = -1, sgn2 = -1;
- if (a[i] == 0)
- sgn1 = 0;
- if (a[i] < 0)
- sgn1 = 1;
- if (a[i + 1] == 0)
- sgn2 = 0;
- if (a[i + 1] < 0)
- sgn2 = 1;
- if (sgn1 > sgn2) {
- int tmp = a[i];
- a[i] = a[i + 1];
- a[i + 1] = tmp;
- flag = 1;
- }
- }
- }
- }
- int f11(int * a, int n, int x) {
- int l = -1, r = n;
- while (l + 1 < r) {
- int m = (l + r) / 2;
- if (a[m] >= x)
- r = m;
- else
- l = m;
- }
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement