Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //AfisareRec
- void afis()
- {
- int x;
- cin >> x;
- if(x != 0 )
- afis();
- cout << x << " ";
- }
- //AfisareVectorRec1
- void afisvec(int v[], int n)
- {
- if(n>0)
- {
- cout<<v[n-1]<<" ";
- afisvec(v,n-1);
- }
- }
- //AfisareVectorRec
- void afisvec(int v[] , int n)
- {
- if(n > 0)
- {
- afisvec( v , n - 1);
- cout << v[n-1] << " ";
- }
- }
- //FSumVecRec
- int suma(int v[],int n,int i,int j)
- {
- if(n==0)
- return 0;
- if(n>=i &&n<=j)
- return suma(v,n-1,i,j);
- else
- return v[n] + suma(v,n-1,i,j);
- }
- //MultipluRec
- int multiplu(int a[],int n,int k)
- {
- int c=0;
- for(int i=0;i<n;i++)
- {
- if(a[i]%10==k&&a[i]%k==0)
- c++;
- }
- return c;
- }
- //FSumRec
- int suma (int v[], int n)
- {
- if(n==1)
- return v[0];
- else
- return(v[n-1]+suma(v,n-1));
- }
- //suma prime
- int prim(int x)
- { int d;
- if(x<2)
- return 0;
- if(x==2)
- return 1;
- if(x%2==0)
- return 0;
- for(d=3;d*d<=x;d+=2)
- if(x%d==0)
- return 0;
- return 1;
- }
- void P(int x[],int n,int &s)
- {
- if(n>0)
- {
- P(x,n-1,s);
- if(prim(x[n-1])==1)
- s += x[n-1];
- }
- else
- s = 0;
- }
- //FSumDiv3Rec
- int sum3(int v[],int n){
- if(n == 0)
- return 0;
- else
- if(v[n-1] % 3 == 0)
- return v[n-1] + sum3(v, n - 1);
- else
- return sum3(v, n - 1);
- }
- //FCautareRec
- int cautare(int n, double X[], double v)
- { for(int i = 0 ; i < n ; i ++)
- if(X[i] == v)
- return i;
- return -1;
- }
- //vocale
- #include<cstring>
- using namespace std;
- int nr_vocale(char s[])
- {
- if(strlen(s)!=0)
- {
- if(strchr("aeiouAEIOU",s[0]))
- return 1+nr_vocale(s+1);
- else
- return nr_vocale(s+1);
- }
- return 0;
- }
- //cmmdc
- #include<iostream>
- using namespace std;
- int cmmdc(int a,int b)
- {
- if(b==0)
- b=a;
- else
- cmmdc(b,a%b);
- }
- //primacif
- #include<iostream>
- using namespace std;
- int primcif(int n)
- {
- if(n<=9)
- return n;
- else
- return primcif(n/10);
- }
- //oglindit
- void oglindit(int n,int ogl)
- {
- if(n<=9)
- return ogl;
- else
- return oglindit(n/10,ogl*10+n%10);
- void cifrep(int n,int &i)
- {
- if(n==0)
- i=0;
- else
- {
- cifrep(n/10,i);
- if(n%2!=0)
- i=i*10+n%10;
- }
- #include<iostream>
- using namespace std;
- int da(int n,int c1,int c2)
- {
- if (n<10)
- {
- if(n==c1)
- return c2;
- else
- return n;
- }
- else
- {
- if(n%10==c1)
- return da(n/10,c1,c2)*10+n%10+c2;
- else
- return da(n/10,c1,c2)*10+n%10;
- }
- #include<iostream>
- using namespace std;
- int maxim(int n)
- {
- if ( n <= 9 )
- return n;
- else
- {
- int m = maxim(n/10);
- if ( m > n%10 )
- return m;
- else
- return n%10;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement