Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. 280
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int n,x,y,p=-1,c=0;
  7. cin>>n;
  8. while(n!=0)
  9. {
  10. x=n;
  11. y=0;
  12. while(x)
  13. y=10*y+x%10,x/=10;
  14. if(y==n)
  15. if(n>p)
  16. p=n,c=1;
  17. else
  18. if(n==p)
  19. c++;
  20. cin>>n;
  21. }
  22. if(p>-1)
  23. cout<<p<<" "<<c;
  24. else
  25. cout<<"NU EXISTA";
  26. return 0;
  27. }
  28.  
  29.  
  30. 1582
  31. #include <iostream>
  32.  
  33. using namespace std;
  34. int n, smin, smax, x, cx, s, xmin, xmax, i;
  35. int main()
  36. {
  37. cin>>n;
  38. smin=100; smax=0;
  39. for ( i=1;i<=n;i++)
  40. {
  41. cin>>x;
  42. cx=x;
  43. s=0;
  44. while (cx>0)
  45. {
  46. s=s+cx%10;
  47. cx=cx/10;
  48. }
  49. if (s<smin)
  50. {
  51. smin=s;
  52. xmin=x;
  53. }
  54. if (s>smax)
  55. {
  56. smax=s;
  57. xmax=x;
  58. }
  59. }
  60. cout<<xmin<<"\n"<<xmax;
  61. return 0;
  62. }
  63.  
  64.  
  65. 372
  66. #include <iostream>
  67. using namespace std;
  68. int main()
  69. {
  70. int n,a ,b,C=0,x,sx,y,sy;
  71. cin >> n >> a;
  72. for(int i = 2 ; i <= n ; ++i)
  73. { cin >> b; x = a; y = b; sx = sy = 0;
  74. while(x)
  75. sx += x % 10,
  76. x /= 10;
  77. while(y)
  78. sy += y % 10,
  79. y /= 10;
  80. if(sx%2 != sy%2)
  81. C++;
  82. a=b; }
  83. cout << C;
  84. return 0; }
  85.  
  86.  
  87. 464
  88. #include <iostream>
  89. using namespace std;
  90. int main()
  91. {
  92. unsigned int k,x,ct=0;
  93. cin>>k>>x;
  94. while(x)
  95. {
  96. if(x%2==0)
  97. {
  98. while(x)
  99. {
  100. if(x%10==k)
  101. ct++;
  102. x/=10;
  103. }
  104. }
  105. cin>>x;
  106. }
  107. cout<<ct;
  108. return 0;
  109. }
  110.  
  111.  
  112. 442
  113. #include <iostream>
  114. #include <math.h>
  115. using namespace std;
  116. int main()
  117. {
  118. long long a=0,b=0,i,n,n2,j,p;
  119. cin>>n; i=0; n2=n;
  120. while(n)
  121. {
  122. n/=10;
  123. i++;
  124. }
  125. n=n2;
  126. p=1;
  127. for(j=1;j<=i/2;j++) {
  128. b=b+p*(n%10);
  129. p*=10;
  130. n/=10;
  131. }
  132. if(i%2) n/=10;
  133. a=n;
  134. cout<<abs(a-b);
  135. }
  136.  
  137.  
  138. 362
  139. #include <iostream>
  140. using namespace std;
  141. int main()
  142. {
  143. int n,x,c,s=0,i=0;
  144. cin >> n;
  145. x=n;
  146. while(x!=0)
  147. {
  148. c=x%10;
  149. i++;
  150. if(i%2==0)
  151. s+=c;
  152. x/=10;
  153. }
  154. cout << s;
  155. }
  156.  
  157.  
  158. 340
  159. #include <iostream>
  160. using namespace std;
  161. int main()
  162. {
  163. int n,s;
  164. cin>>n;
  165. while(n>9)
  166. {
  167. s=0;
  168. while (n>0)
  169. {
  170. s=s+n%10;
  171. n=n/10;
  172. }
  173. n=s;
  174. }
  175. cout<<n;
  176. return 0;
  177. }
  178.  
  179.  
  180. 2221
  181. #include <iostream>
  182. using namespace std;
  183. int main()
  184. {
  185. int n, nr = 0;
  186. cin >> n;
  187. int cn = n;
  188. while(cn > 0)
  189. {
  190. nr++;
  191. cn = cn / 10;
  192. }
  193. int cnt = 0;
  194. for(int i=0; i<nr; i++)
  195. {
  196. cn=n;
  197. int poz=0,nnou=0,p=1;
  198. while(cn>0)
  199. {
  200. if(poz!=i)
  201. {
  202. nnou=nnou+(cn%10)*p;
  203. p=p*10;
  204. }
  205. cn=cn/10;
  206. poz++;
  207. }
  208. if(nnou%3==0)
  209. cnt++;
  210. }
  211. cout<<cnt;
  212. return 0;
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement