Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
2015(M2)Mod.
//g++ 7.4.0 #include <iostream> using namespace std; /*bool subperfect(int n) { int s = 0; for(int i = 2; i < n; i ++) { if(n % i == 0) { s = s + i; } } if(n < s) { return true; } else { return false; } } int main() { int a, b, c = 0; cin>>a>>b; for(int i = b; i >= a; i--) { if(subperfect(i)) { cout<<i<<" "; c++; } } if(c == 0) { cout<<"Nu exista"; } }*/ /*int main() { int n, i, c = 0; cin>>n; int v[n]; for(i = 0; c < n; i++) { if(i % 3 != 0 && i % 2 != 0) { v[c] = i; c++; } } for(i = c - 1; i >= 0; i--) { cout<<v[i]<<" "; } }*/ int main() { #include <math.h> using namespace std; #include <fstream> ifstream fin("bac.txt"); int Cautare_binara(int l, int r, int x, int v[]) { int m = (r + l)/2; if(abs(l-r) <= 1)//v[m] == x:return m; { return l; } cout << l << r << endl; if(x > v[m]) { cout << "stanga" << endl;; return Cautare_binara(l, m, x, v); } cout << "dreapta" << endl;; return Cautare_binara(m + 1, r, x, v); } int main() { int n, x; fin>>n; int v[n]; for(int i = 0; i < n; i++) { fin>>v[i]; } fin>>x; cout<<v[Cautare_binara( 0, n-1, x, v)]; } }
run
|
edit
|
history
|
help
0
Find the max and min number in array
Test 12(2021)
Anziktet
star print 2
1234
string
Vector impl
Double_wrapper gcc
swastic
Void main