Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.27 KB | None | 0 0
  1. // 1
  2. #include <iomanip>
  3. #include <iostream>
  4. #include <cmath>
  5. using namespace std;
  6. void nuskaitymas (int &n, int A[]);
  7. int suma (int n, int A[]);
  8. int main () {
  9.     int n;
  10.     int A[100000];
  11.     nuskaitymas(n, A);
  12.     cout << suma(n, A) << endl;
  13.     return 0;
  14. }
  15. void nuskaitymas (int &n, int A[]){
  16.     cin >> n;
  17.     for (int i = 0; i < n; i++){
  18.         cin >> A[i];
  19.     }
  20. }
  21. int suma (int n, int A[]){
  22.     int sum = 0;
  23.     for (int i = 0; i < n; i++){
  24.         sum += A[i];
  25.     }
  26.     return sum;
  27. }
  28. ////////////////////////////////
  29.  
  30. //2
  31.  
  32. #include <iomanip>
  33. #include <iostream>
  34. #include <cmath>
  35. using namespace std;
  36. int main () {
  37.     int n;
  38.     int A[11];
  39.     int suma = 0, x = 0;
  40.     double vidurkis = 0;
  41.     cin >> n;
  42.     for (int i = 0; i < n; i++){
  43.         cin >> A[i];
  44.         if (A[i] < 0){
  45.             suma += A[i];
  46.             x++;
  47.         }
  48.     }
  49.     if (x == 0) cout << "NO";
  50.     else {
  51.         vidurkis = suma * 0.1 * 10 / x;
  52.         cout << fixed << setprecision(2) << vidurkis;
  53.     }
  54.    
  55.     return 0;
  56. }
  57.  
  58. //////////////////
  59.  
  60. // 3
  61. #include <iomanip>
  62. #include <iostream>
  63. #include <cmath>
  64. using namespace std;
  65.  
  66. void skaitymas (int A[], int &n);
  67.  
  68. int main () {
  69.     int n;
  70.     int A[11];
  71.     int vieta = 0;
  72.     int x = 0;
  73.     int kint = 1000001;
  74.     skaitymas(A, n);
  75.     for (int i = 0; i < n; i++){
  76.         if ((A[i] != 0) && (A[i] % 2 == 0)){
  77.          if (A[i] < kint){
  78.             kint = A[i];
  79.             vieta = i;
  80.             x++;
  81.          }
  82.     }
  83.     }
  84.     if (x > 0) cout << A[vieta];
  85.     else cout << "No";
  86.     return 0;
  87. }
  88.  
  89. void skaitymas (int A[], int &n)
  90. {
  91.     cin >> n;
  92.     for (int i = 0; i < n; i++){
  93.         cin >> A[i];
  94.     }
  95. }
  96.  
  97. //////////////////////
  98.  
  99. // 5
  100.  
  101. #include <iomanip>
  102. #include <iostream>
  103. #include <cmath>
  104. using namespace std;
  105. int main ()
  106. {
  107.     int n;
  108.     int A[11];
  109.     int x = 0;
  110.     cin >> n;
  111.     for (int i = 0; i < n; i++){
  112.         cin >> A[i];
  113.     }
  114.     for (int i = 0; i < n; i++){
  115.         for (int j = i+1; j < n; j++){
  116.             if (A[i] == A[j]) x++;
  117.         }
  118.     }
  119.     if (x > 0) cout << "NE";
  120.     else cout << "TAIP";
  121.    
  122.    
  123.     return 0;
  124. }
  125.  
  126. //////////////////////////////////
  127.  
  128. // 8
  129.  
  130. #include <iomanip>
  131. #include <iostream>
  132. #include <cmath>
  133. using namespace std;
  134. void input (int A[][12], int &n, int &m, int &k);
  135. int suma (int A[][12], int n, int m, int k);
  136. int main ()
  137. {
  138.     int n, m, k;
  139.     int A[12][12];
  140.     int sum;
  141.     input(A, n, m, k);
  142.     sum = suma(A, n, m, k);
  143.     if (k < m) cout << sum;
  144.     else cout << "NO";
  145.     return 0;
  146. }
  147. void input (int A[][12], int &n, int &m, int &k)
  148. {
  149.     cin >> n >> m >> k;
  150.     for (int i = 0; i < n; i++){
  151.         for (int j = 0; j < m; j++){
  152.             cin >> A[i][j];
  153.         }
  154.     }
  155. }
  156. int suma (int A[][12], int n, int m, int k)
  157. {
  158.     int suma = 0;
  159.     for (int i = 0; i < n; i++){
  160.         for (int j = k; j < m; j++){
  161.             suma += A[i][j];
  162.         }
  163.     }
  164.     return suma;
  165. }
  166.  
  167. /////////////////////////////
  168.  
  169. // 9
  170.  
  171. #include <iomanip>
  172. #include <iostream>
  173. #include <cmath>
  174. using namespace std;
  175. void input (int A[][12], int &n, int &m);
  176. int didzVieta (int A[][12], int n, int m);
  177. double vidurkis (int A[][12], int n, int m, int max);
  178. int main ()
  179. {
  180.     int n, m;
  181.     int A[12][12];
  182.     int max;
  183.     double vid;
  184.     input(A, n, m);
  185.     max = didzVieta(A, n, m);
  186.     vid = vidurkis(A, n, m, max);
  187.     cout << fixed << setprecision(2) << vid;
  188.     return 0;
  189. }
  190. void input (int A[][12], int &n, int &m)
  191. {
  192.     cin >> n >> m;
  193.     for (int i = 0; i < n; i++){
  194.         for (int j = 0; j < m; j++){
  195.             cin >> A[i][j];
  196.         }
  197.     }
  198. }
  199. int didzVieta (int A[][12], int n, int m)
  200. {
  201.     int x = 0, y = 0;
  202.     for (int i = 0; i < n; i++){
  203.         for (int j = 0; j < m; j++){
  204.             if (A[i][j] > A[x][y]){
  205.                 x = i;
  206.                 y = j;
  207.             }
  208.         }
  209.     }
  210.     return x;
  211. }
  212. double vidurkis (int A[][12], int n, int m, int max)
  213. {
  214.     int suma = 0;
  215.     double vid = 0;
  216.     for (int j = 0; j < m; j++){
  217.         suma += A[max][j];
  218.         vid++;
  219.     }
  220.     vid = suma * 0.1 * 10 / vid;
  221.     return vid;
  222. }
  223.  
  224. /////////////////////////////////
  225.  
  226. // 10
  227.  
  228. #include <iomanip>
  229. #include <iostream>
  230. #include <cmath>
  231. using namespace std;
  232. void input (int A[][12], int &n);
  233. int suma (int A[][12], int n);
  234. int main ()
  235. {
  236.     int n;
  237.     int A[12][12];
  238.     int sum;
  239.     input(A, n);
  240.     sum = suma(A, n);
  241.     if (n > 1) cout << sum;
  242.     else cout << "No";
  243.     return 0;
  244. }
  245. void input (int A[][12], int &n)
  246. {
  247.     cin >> n;
  248.     for (int i = 0; i < n; i++){
  249.         for (int j = 0; j < n; j++){
  250.             cin >> A[i][j];
  251.         }
  252.     }
  253. }
  254. int suma (int A[][12], int n)
  255. {
  256.     int suma = 0;
  257.     for (int i = 0; i < n; i++){
  258.         for (int j = 0; j < n; j++){
  259.             if (i > j) suma += A[i][j];
  260.         }
  261.     }
  262.     return suma;
  263. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement