SHARE
TWEET

Untitled

a guest Oct 15th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double average(int k);
  5.  
  6. int main() {
  7.     setlocale(LC_ALL, "Russian");
  8.     int k = 0;
  9.     cout << "Введите k: " << endl;
  10.     cin >> k;
  11.     cout << "Среднее арифметическое значение вводимой последовательности чисел:  " << average(k) << endl;
  12.  
  13.     return 0;
  14. }
  15.  
  16. double average(int k){
  17.     int sum = 0;
  18.     int tmp = 0;
  19.     int i = 0;
  20.     cout << "Введите числа: " << endl;
  21.     do {
  22.         cin >> tmp;
  23.         sum += tmp;
  24.         i++;
  25.     }
  26.     while ( i < k );
  27.     return sum / k;
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top