#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int losuj(int min, int max) {
int tmp;
if (max >= min)
max -= min;
else {
tmp = min - max;
min = max;
max = tmp;
}
return max ? (rand() % max + min) : min;
}
int binarne(int tab[], int x, int n) {
int left = 0, right = n - 1;
int found = 0, m;
while(right - left >= 0 && found == 0) {
m = (left + right) / 2;
if(x == tab[m]) {
found = 1;
} else {
if(x < tab[m]) {
right = m - 1;
} else {
left = m + 1;
}
}
}
if(found == 1) {
return m;
} else {
return -1;
}
}
int main() {
int tab[2000], j = 0;
for (j = 0; j < 2000; j++) {
tab[j] = j + 1;
}
int a = losuj(0, 2000);
printf("%d %d\n", a, binarne(tab, a, 2000));
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}