Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. //AfisareRec
  2.  
  3. void afis()
  4. {
  5. int x;
  6. cin >> x;
  7. if(x != 0 )
  8. afis();
  9. cout << x << " ";
  10. }
  11.  
  12. //AfisareVectorRec1
  13.  
  14. void afisvec(int v[], int n)
  15. {
  16. if(n>0)
  17. {
  18. cout<<v[n-1]<<" ";
  19. afisvec(v,n-1);
  20. }
  21.  
  22. }
  23.  
  24.  
  25. //AfisareVectorRec
  26. void afisvec(int v[] , int n)
  27. {
  28. if(n > 0)
  29. {
  30. afisvec( v , n - 1);
  31. cout << v[n-1] << " ";
  32. }
  33. }
  34.  
  35. //FSumVecRec
  36.  
  37. int suma(int v[],int n,int i,int j)
  38. {
  39. if(n==0)
  40. return 0;
  41. if(n>=i &&n<=j)
  42. return suma(v,n-1,i,j);
  43. else
  44. return v[n] + suma(v,n-1,i,j);
  45. }
  46.  
  47. //MultipluRec
  48. int multiplu(int a[],int n,int k)
  49. {
  50. int c=0;
  51. for(int i=0;i<n;i++)
  52. {
  53. if(a[i]%10==k&&a[i]%k==0)
  54. c++;
  55. }
  56. return c;
  57. }
  58.  
  59. //FSumRec
  60.  
  61. int suma (int v[], int n)
  62.  
  63. {
  64.  
  65. if(n==1)
  66. return v[0];
  67.  
  68. else
  69. return(v[n-1]+suma(v,n-1));
  70.  
  71. }
  72.  
  73. //suma prime
  74.  
  75.  
  76. int prim(int x)
  77. { int d;
  78. if(x<2)
  79. return 0;
  80. if(x==2)
  81. return 1;
  82. if(x%2==0)
  83. return 0;
  84.  
  85. for(d=3;d*d<=x;d+=2)
  86. if(x%d==0)
  87. return 0;
  88.  
  89. return 1;
  90.  
  91. }
  92. void P(int x[],int n,int &s)
  93. {
  94. if(n>0)
  95. {
  96. P(x,n-1,s);
  97.  
  98. if(prim(x[n-1])==1)
  99. s += x[n-1];
  100.  
  101. }
  102. else
  103. s = 0;
  104.  
  105.  
  106. }
  107.  
  108. //FSumDiv3Rec
  109.  
  110. int sum3(int v[],int n){
  111.  
  112. if(n == 0)
  113.  
  114. return 0;
  115.  
  116. else
  117.  
  118. if(v[n-1] % 3 == 0)
  119.  
  120. return v[n-1] + sum3(v, n - 1);
  121.  
  122. else
  123.  
  124. return sum3(v, n - 1);
  125.  
  126. }
  127.  
  128. //FCautareRec
  129.  
  130. int cautare(int n, double X[], double v)
  131. { for(int i = 0 ; i < n ; i ++)
  132. if(X[i] == v)
  133. return i;
  134. return -1;
  135. }
  136.  
  137. //vocale
  138.  
  139. #include<cstring>
  140. using namespace std;
  141. int nr_vocale(char s[])
  142. {
  143. if(strlen(s)!=0)
  144. {
  145. if(strchr("aeiouAEIOU",s[0]))
  146. return 1+nr_vocale(s+1);
  147. else
  148. return nr_vocale(s+1);
  149.  
  150.  
  151. }
  152. return 0;
  153. }
  154.  
  155. //cmmdc
  156.  
  157. #include<iostream>
  158. using namespace std;
  159. int cmmdc(int a,int b)
  160. {
  161. if(b==0)
  162. b=a;
  163. else
  164. cmmdc(b,a%b);
  165. }
  166.  
  167. //primacif
  168.  
  169.  
  170. #include<iostream>
  171. using namespace std;
  172. int primcif(int n)
  173. {
  174. if(n<=9)
  175. return n;
  176. else
  177. return primcif(n/10);
  178.  
  179. }
  180.  
  181. //oglindit
  182.  
  183. void oglindit(int n,int ogl)
  184. {
  185. if(n<=9)
  186. return ogl;
  187. else
  188. return oglindit(n/10,ogl*10+n%10);
  189.  
  190.  
  191. void cifrep(int n,int &i)
  192. {
  193. if(n==0)
  194. i=0;
  195. else
  196. {
  197. cifrep(n/10,i);
  198. if(n%2!=0)
  199. i=i*10+n%10;
  200. }
  201.  
  202. #include<iostream>
  203. using namespace std;
  204. int da(int n,int c1,int c2)
  205. {
  206. if (n<10)
  207. {
  208. if(n==c1)
  209. return c2;
  210. else
  211. return n;
  212. }
  213.  
  214. else
  215.  
  216. {
  217. if(n%10==c1)
  218. return da(n/10,c1,c2)*10+n%10+c2;
  219. else
  220. return da(n/10,c1,c2)*10+n%10;
  221. }
  222.  
  223. #include<iostream>
  224. using namespace std;
  225. int maxim(int n)
  226. {
  227.  
  228. if ( n <= 9 )
  229. return n;
  230. else
  231. {
  232. int m = maxim(n/10);
  233. if ( m > n%10 )
  234. return m;
  235. else
  236. return n%10;
  237. }
  238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement