Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void Divizeaza(int s, int d, int &m)
  6. {
  7.     m=(s+d)/2;
  8. }
  9. int ecuatie(int a,int b,int c,int nr)
  10. {
  11.     return a*nr*nr+b*nr+c;
  12. }
  13.  
  14.  
  15. void Dei(int v[100],int s,int d,int a,int b, int c,int &z)
  16. {
  17.     int m;
  18.     if(s<d)
  19.     {
  20.         Divizeaza(s,d,m);
  21.         Dei(v,s,m,a,b,c,z);
  22.         Dei(v,m+1,d,a,b,c,z);
  23.     }
  24.     else
  25.         if(ecuatie(a,b,c,v[s])==0)
  26.             z++;
  27.  
  28. }
  29.  
  30. int main()
  31. {
  32.     int v[100],n,z=0,a,b,c;
  33.     cout<<"a=";cin>>a;
  34.     cout<<"b=";cin>>b;
  35.     cout<<"c=";cin>>c;
  36.     cout<<"n=";cin>>n;
  37.     for(int i=0;i<n;i++)
  38.         cin>>v[i];
  39.     Dei(v, 0, n-1,a,b,c,z);
  40.    cout<<z;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement