Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <windows.h>
  5. #include <math.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. SetConsoleCP(1251);
  12. SetConsoleOutputCP(1251);
  13.    int i, n;
  14.    int arr[100],arrc[100],arrn[100];
  15.    int a,k=0,l;
  16.    float geo;
  17. string x= "Четные : ";
  18. string z= "Нечетные : ";
  19.    ofstream f ("f.txt");
  20.      ofstream g("g.txt");
  21.        ofstream h("h.txt");
  22.      cout<<"Введите количество чисел : "<<endl; cin>>n;
  23.      g<<x;
  24.      h<<z;
  25.      for(int i = 0;i<n;i++)
  26.        {
  27.          cout<<"Введите число : "<<endl; cin>>a;
  28.            arr[i]=a;
  29.              f<<" "<<a;
  30.                if(arr[i]%2 == 0)
  31.                        {
  32.                            arrc[i] = arr[i];
  33.                              g<<arrc[i]<<"  ";
  34.                               k++;
  35.                           }
  36.                 else
  37.                 {
  38.                     arrn[i] = arr[i];
  39.                       h<<arrn[i]<<"  ";
  40.                        l++;
  41.                 }
  42.  
  43.  
  44.        }
  45.        f.close();
  46.        int q = 1;
  47.       // float y = 1./k.;
  48.        for(int i = 0;i<n;i++)
  49.         {
  50.             q=q*arrc[i];
  51.  
  52.             geo = pow(q,1.0/k);
  53.  
  54.         }
  55.          cout<<"Среднее геометрическое : "<<geo;
  56.          g.close();
  57.          h.close();
  58.       system("pause");
  59.          return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement