Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. /*
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int oglinda(int x)
  6. {
  7. int aux=0;
  8. while(x){
  9. aux=aux*10+x%10;
  10. x/=10;
  11.  
  12. }
  13. return aux;
  14. }
  15.  
  16. int main()
  17. {
  18. cout<<oglinda(1234);
  19.  
  20. return 0;
  21. }
  22.  
  23.  
  24. #include <iostream>
  25. using namespace std;
  26.  
  27. int maxim(int x)
  28. {
  29. int V[15],n=0, ok, aux, nr=0;
  30.  
  31. while(x){
  32. V[++n]=x%10;
  33. x/=10;
  34. }
  35.  
  36. do{
  37. ok=1;
  38. for(int i=1;i<n;i++)
  39. if(V[i]<V[i+1]){
  40. aux=V[i];
  41. V[i]=V[i+1];
  42. V[i+1]=aux;
  43. ok=0;
  44. }
  45. }while(!ok);
  46.  
  47. for(int i=1;i<=n;i++)
  48. nr=nr*10+V[i];
  49.  
  50. return nr;
  51. }
  52.  
  53. int main()
  54. {
  55. cout<<maxim(93678);
  56.  
  57. return 0;
  58. }
  59.  
  60.  
  61. #include <iostream>
  62. #include <math.h>
  63. using namespace std;
  64.  
  65. int concat(int a, int b)
  66. {
  67. int c1=0, aux, nr;
  68.  
  69.  
  70. aux=b;
  71. while(aux){
  72. c1++;
  73. aux/=10;
  74. }
  75.  
  76.  
  77. nr=a*pow(10, c1)+b;
  78.  
  79. return nr;
  80. }
  81.  
  82. int main()
  83. {
  84. cout<<concat(123, 321);
  85.  
  86. return 0;
  87. }
  88.  
  89.  
  90. #include <iostream>
  91. using namespace std;
  92.  
  93. int nr_prim(int a)
  94. {
  95. int i,ok=1;
  96.  
  97. for(i=2;i*i<=a&&ok==1;i++)
  98. if(a%i==0)
  99. ok=0;
  100.  
  101. return ok;
  102. }
  103.  
  104. int main()
  105. {
  106. if(nr_prim(123))
  107. cout<<"Numarul este prim!";
  108. else
  109. cout<<"Numarul nu este prim!";
  110.  
  111.  
  112. return 0;
  113. }
  114.  
  115.  
  116. #include <iostream>
  117. using namespace std;
  118.  
  119. int s_div(int a)
  120. {
  121. int i,s=0;
  122. for(i=2;i<=a;i++)
  123. if(a%i==0)
  124. s+=i;
  125.  
  126. return s;
  127. }
  128.  
  129. int main()
  130. {
  131. cout<<s_div(10);
  132.  
  133. return 0;
  134. }
  135.  
  136.  
  137. #include <iostream>
  138. using namespace std;
  139.  
  140. int nr_zero(int a)
  141. {
  142. int c=0;
  143.  
  144. while(a){
  145. if(a%10 == 0)
  146. c++;
  147. a/=10;
  148. }
  149.  
  150. return c;
  151. }
  152.  
  153. int main()
  154. {
  155. cout<<nr_zero(10293010);
  156.  
  157. return 0;
  158. }
  159.  
  160.  
  161. #include <iostream>
  162. using namespace std;
  163.  
  164. void ulc_para(int a)
  165. {
  166. int gasit=0;
  167.  
  168. while(a && !gasit){
  169. if((a%10)%2 == 0)
  170. gasit=1;
  171. else
  172. a/=10;
  173. }
  174.  
  175. if(gasit)
  176. cout<<"Ultima cifra para este: "<<a%10;
  177. else
  178. cout<<"Nu exista numere pare!";
  179. }
  180.  
  181. int main()
  182. {
  183. ulc_para(11111);
  184.  
  185. return 0;
  186. }
  187.  
  188. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement