Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <windows.h>
- #include <math.h>
- using namespace std;
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int i, n;
- int arr[100],arrc[100],arrn[100];
- int a,k=0,l;
- float geo;
- string x= "Четные : ";
- string z= "Нечетные : ";
- ofstream f ("f.txt");
- ofstream g("g.txt");
- ofstream h("h.txt");
- cout<<"Введите количество чисел : "<<endl; cin>>n;
- g<<x;
- h<<z;
- for(int i = 0;i<n;i++)
- {
- cout<<"Введите число : "<<endl; cin>>a;
- arr[i]=a;
- f<<" "<<a;
- if(arr[i]%2 == 0)
- {
- arrc[i] = arr[i];
- g<<arrc[i]<<" ";
- k++;
- }
- else
- {
- arrn[i] = arr[i];
- h<<arrn[i]<<" ";
- l++;
- }
- }
- f.close();
- int q = 1;
- // float y = 1./k.;
- for(int i = 0;i<n;i++)
- {
- q=q*arrc[i];
- geo = pow(q,1.0/k);
- }
- cout<<"Среднее геометрическое : "<<geo;
- g.close();
- h.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement