Advertisement
mercMatvey4

Untitled

Dec 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. //ChuvSU yandex.contest 20!8
  2. //Matvey&Volodya 21-18
  3. //Compiler == GNU c++11 4.9
  4.  
  5. //1
  6.  
  7. #include <iostream>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. int n, sum=0;
  14. cin >> n;
  15. int a[n];
  16. for (int i=0;i<n;i++)
  17. cin >> a[i];
  18. for (int i=0;i<n;i++)
  19. sum+=a[i];
  20. cout<<sum;
  21. }
  22.  
  23. //2
  24.  
  25. #include <iostream>
  26. using namespace std;
  27.  
  28. int main()
  29. {
  30. int n,temp=0,len=0,m=0,max_len=0;
  31. cin >> n;
  32. int a[n];
  33. for (int i=0; i<n; i++)
  34. cin >> a[i];
  35. for (int i=1; i<n; i++)
  36. {
  37. if(a[i]<a[i-1])
  38. len++;
  39. else{
  40. if(len>max_len)
  41. {
  42. max_len=len;
  43. m=temp;
  44. }
  45. len=0;
  46. temp=i;
  47. }
  48. }
  49. if(max_len>len)
  50. {
  51. len=max_len;
  52. temp=m;
  53. }
  54. max_len=0;
  55. for(int i=temp; i<=temp+len; i++) max_len++;
  56. cout << max_len;
  57. }
  58.  
  59. //5
  60.  
  61. #include <iostream>
  62.  
  63. using namespace std;
  64.  
  65. int main()
  66. {
  67. int N;
  68. cin >> N;
  69. int a[N];
  70. for (int i=0;i<N;i++)
  71. cin >> a[i];
  72. for (int i=0;i<N;i++)
  73. if ((a[i]%2)!=0) cout << a[i] << " ";
  74. for (int i = 0; i < N; i++)
  75. if ((a[i]%2)==0) cout << a[i] << " ";
  76. return 0;
  77. }
  78.  
  79. //6
  80.  
  81. #include <iostream>
  82.  
  83. using namespace std;
  84.  
  85. int main()
  86. {
  87. int N,i;
  88. cin >> N;
  89. int a[N];
  90. for (int i=0;i<N;i++)
  91. cin >> a[i];
  92. for (int i=0;i<N;i++){
  93. if ((a[i]%2)==0) cout << a[i] << " ";}
  94. for (int i = 0; i < N; i++){
  95. if ((a[i]%2)!=0) cout << a[i] << " ";}
  96. return 0;
  97. }
  98.  
  99.  
  100. //7
  101.  
  102. #include <iostream>
  103.  
  104. using namespace std;
  105.  
  106. int main()
  107. {
  108. float AvgSum,Sum=0,Count=0;
  109. int N;
  110. cin >> N;
  111. int a[N];
  112. for (int i = 0; i < N; i++)
  113. cin >> a[i];
  114. for (int i = 0; i < N; i++)
  115. {
  116. if (a[i]>0)
  117. {
  118. Sum+=a[i];
  119. Count++;
  120. }
  121. }
  122. if (Count==0)
  123. AvgSum=0;
  124. else AvgSum=Sum/Count;
  125. for (int i = 0; i < N; i++)
  126. {
  127. if (a[i]<=AvgSum)
  128. cout << a[i] << " ";
  129. }
  130. }
  131.  
  132. //8
  133.  
  134. #include <iostream>
  135.  
  136. using namespace std;
  137.  
  138. int main()
  139. {
  140. int N,Count=0;
  141. int m;
  142. cin >> N;
  143. int a[N];
  144. for (int i=0;i<N;i++)
  145. cin >> a[i];
  146. cin >> m;
  147. for (int i=0;i<N;i++)
  148. if (a[i]==m*m) {cout << a[i] << " "; Count++;}
  149. if (Count==0) cout << "NO";
  150. return 0;
  151. }
  152.  
  153.  
  154. //9
  155.  
  156. #include <iostream>
  157.  
  158. using namespace std;
  159.  
  160. int main()
  161. {
  162. int N;
  163. cin >> N;
  164. int a[N];
  165. for (int i = 0; i < N; ++i)
  166. cin >> a[i];
  167. for (int i = 0; i < N; ++i)
  168. {
  169. if (a[i]!=0) cout << a[i] << " ";
  170. }
  171. return 0;
  172. }
  173.  
  174. //10
  175.  
  176. #include <iostream>
  177.  
  178. using namespace std;
  179.  
  180. int main()
  181. {
  182. int N;
  183. cin >> N;
  184. int a[N];
  185. for (int i = 0; i < N; ++i)
  186. cin >> a[i];
  187. for (int i = N; i >= 1; --i)
  188. for (int j = 0; j < i; ++j)
  189. {
  190. if(a[j]==0)
  191. {
  192. int temp = a[j];
  193. a[j] = a[j-1];
  194. a[j-1] = temp;
  195. }
  196. }
  197. for (int i = 0; i < N; ++i)
  198. cout << a[i] << " ";
  199. return 0;
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement