Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pt4.h"
- #include <fstream>
- using namespace std;
- void Solve()
- {
- Task("TextFile5");
- ifstream f;
- int now, s = 0, c = 0;
- f.open("a.num",ios::in);
- while (!f.eof())
- {
- f » now;
- s += now;
- c++;
- }
- f.close();
- pt « double(s) / c;
- }
- #include "pt4.h"
- #include <fstream>
- using namespace std;
- bool ch(int x)
- {
- bool a = true;
- int cop = x, c;
- while (x != 0)
- {
- c = x % 10;
- if (c == 0 || cop % c != 0)
- a = false;
- x /= 10;
- }
- return (a);
- }
- void Solve()
- {
- Task("TextFile14");
- ofstream f;
- int n;
- f.open("f.dat", ios::out);
- pt » n;
- for (int i = 1; i <= n; i++)
- if (ch(i))
- f « i « endl;
- f.close();
- }
- #include "pt4.h"
- #include <fstream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- double LenOtr(int x1, int y1, int x2, int y2)
- {
- return(hypot(abs(x1 - x2), abs(y1 - y2)));
- }
- void Solve()
- {
- Task("TheTri3");
- ifstream f;
- int n, x1, x2, y1, y2, mc = 0;
- double maxi = -1;
- f.open("c.otr",ios::in);
- f » n;
- for (int i = 0; i < n; i++)
- {
- f » x1 » y1 » x2 » y2;
- if (LenOtr(x1, y1, x2, y2) > maxi)
- {
- maxi = LenOtr(x1, y1, x2, y2);
- mc = i + 1;
- }
- }
- pt « mc;
- f.close();
- }
- #include "pt4.h"
- #include <string>
- #include <fstream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- int P(int x, int y, int z)
- {
- return (x + y + z);
- }
- double S(int x, int y, int z)
- {
- double p;
- p = (x + y + z) / 2.0;
- return (sqrt(p * (p - x) * (p - y) * (p - z)));
- }
- void Solve()
- {
- Task("Tri3");
- string n1, n2;
- ifstream A;
- ofstream B;
- pt » n1 » n2;
- A.open(n1, ios::in);
- B.open(n2, ios::out);
- int n, x, y, z;
- A » n;
- for (int i = 0; i < n; i++)
- {
- A » x » y » z;
- if (x + y > z && x + z > y && y + z > x)
- B « fixed « setprecision(2) « x « ' ' « y « ' ' « z « ' ' « P(x, y, z) « ' ' « S(x, y, z) « endl;
- }
- A.close();
- B.close();
- }
- #include <iostream>
- using namespace std;
- int gcd (int a, int b)
- {
- while (b != 0)
- {
- a %= b;
- swap (a, b);
- }
- return a;
- }
- int lcm (int a, int b)
- {
- return (a / gcd (a, b) * b);
- }
- void SumDr(int &a1, int &b1, int a2, int b2)
- {
- a1 = a1 * (lcm (b1, b2) / b1) + a2 * (lcm (b1, b2) / b2);
- b1 = lcm (b1, b2);
- }
- void Co(int a, int b)
- {
- cout « a « '/' « b;
- }
- int main()
- {
- int n, a1 = 1, b1 = 1, a = 1, b = 1;
- cin » n;
- for (int i = 0; i < n - 1; i++)
- {
- a1 *= (-1);
- b1++;
- SumDr (a, b, a1, b1);
- }
- Co(a, b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement