Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #define size 100
- using namespace std;
- template <class T>
- T FindX (T a, T b)
- {
- T x;
- if (a>b) x=a/b-1;
- if (a==b) x=a+25;
- if (a<b) x=(a*b-2)/a;
- return x;
- }
- int MasSol(int* A, int n)
- {
- int* MinusA = new int[size];
- int cnt=0;
- for (int i=0; i<n; i++)
- {
- if (A[i]<0)
- {
- MinusA[cnt]=A[i];
- cnt++;
- }
- }
- int P=1;
- for (int i=0; i<cnt; i++)
- P=P*MinusA[i]*MinusA[i]*MinusA[i];
- delete [] MinusA;
- return P;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- // часть 1
- ifstream IN;
- IN.open("C:\\1\\in.txt");
- int a,b,ans1;
- float c,d,ans2;
- IN >> a >> b >> c >> d;
- ans1=FindX(a,b);
- ans2=FindX(c,d);
- ofstream ANS1;
- ANS1.open("C:\\1\\in.txt", ios::app);
- ANS1 << "\n" << ans1 << "\n" << ans2;
- // часть 2
- ifstream MAS;
- MAS.open("C:\\1\\mas.txt");
- int* A = new int[size];
- int cnt=0;
- while (!MAS.eof())
- {
- MAS >> A[cnt];
- cnt++;
- }
- int P=MasSol(A,cnt);
- delete [] A;
- ofstream ANS2;
- ANS2.open("c:\\1\\mas.txt", ios::app);
- ANS2 << "\n" << P;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement