Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. #include "pt4.h"
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. void Solve()
  6. {
  7. Task("TextFile5");
  8. ifstream f;
  9. int now, s = 0, c = 0;
  10. f.open("a.num",ios::in);
  11. while (!f.eof())
  12. {
  13. f » now;
  14. s += now;
  15. c++;
  16. }
  17. f.close();
  18. pt « double(s) / c;
  19. }
  20.  
  21.  
  22.  
  23. #include "pt4.h"
  24. #include <fstream>
  25. using namespace std;
  26.  
  27. bool ch(int x)
  28. {
  29. bool a = true;
  30. int cop = x, c;
  31. while (x != 0)
  32. {
  33. c = x % 10;
  34. if (c == 0 || cop % c != 0)
  35. a = false;
  36. x /= 10;
  37. }
  38. return (a);
  39. }
  40.  
  41. void Solve()
  42. {
  43. Task("TextFile14");
  44. ofstream f;
  45. int n;
  46. f.open("f.dat", ios::out);
  47. pt » n;
  48. for (int i = 1; i <= n; i++)
  49. if (ch(i))
  50. f « i « endl;
  51. f.close();
  52. }
  53.  
  54.  
  55.  
  56. #include "pt4.h"
  57. #include <fstream>
  58. #include <math.h>
  59. #include <cmath>
  60. using namespace std;
  61.  
  62. double LenOtr(int x1, int y1, int x2, int y2)
  63. {
  64. return(hypot(abs(x1 - x2), abs(y1 - y2)));
  65. }
  66.  
  67. void Solve()
  68. {
  69. Task("TheTri3");
  70. ifstream f;
  71. int n, x1, x2, y1, y2, mc = 0;
  72. double maxi = -1;
  73. f.open("c.otr",ios::in);
  74. f » n;
  75. for (int i = 0; i < n; i++)
  76. {
  77. f » x1 » y1 » x2 » y2;
  78. if (LenOtr(x1, y1, x2, y2) > maxi)
  79. {
  80. maxi = LenOtr(x1, y1, x2, y2);
  81. mc = i + 1;
  82. }
  83. }
  84. pt « mc;
  85. f.close();
  86. }
  87.  
  88.  
  89.  
  90.  
  91.  
  92. #include "pt4.h"
  93. #include <string>
  94. #include <fstream>
  95. #include <math.h>
  96. #include <iomanip>
  97. using namespace std;
  98.  
  99. int P(int x, int y, int z)
  100. {
  101. return (x + y + z);
  102. }
  103.  
  104. double S(int x, int y, int z)
  105. {
  106. double p;
  107. p = (x + y + z) / 2.0;
  108. return (sqrt(p * (p - x) * (p - y) * (p - z)));
  109. }
  110.  
  111. void Solve()
  112. {
  113. Task("Tri3");
  114. string n1, n2;
  115. ifstream A;
  116. ofstream B;
  117. pt » n1 » n2;
  118. A.open(n1, ios::in);
  119. B.open(n2, ios::out);
  120. int n, x, y, z;
  121. A » n;
  122. for (int i = 0; i < n; i++)
  123. {
  124. A » x » y » z;
  125. if (x + y > z && x + z > y && y + z > x)
  126. B « fixed « setprecision(2) « x « ' ' « y « ' ' « z « ' ' « P(x, y, z) « ' ' « S(x, y, z) « endl;
  127. }
  128. A.close();
  129. B.close();
  130. }
  131.  
  132.  
  133.  
  134. #include <iostream>
  135.  
  136. using namespace std;
  137.  
  138. int gcd (int a, int b)
  139. {
  140. while (b != 0)
  141. {
  142. a %= b;
  143. swap (a, b);
  144. }
  145. return a;
  146. }
  147.  
  148. int lcm (int a, int b)
  149. {
  150. return (a / gcd (a, b) * b);
  151. }
  152.  
  153. void SumDr(int &a1, int &b1, int a2, int b2)
  154. {
  155. a1 = a1 * (lcm (b1, b2) / b1) + a2 * (lcm (b1, b2) / b2);
  156. b1 = lcm (b1, b2);
  157. }
  158.  
  159. void Co(int a, int b)
  160. {
  161. cout « a « '/' « b;
  162. }
  163.  
  164. int main()
  165. {
  166. int n, a1 = 1, b1 = 1, a = 1, b = 1;
  167. cin » n;
  168. for (int i = 0; i < n - 1; i++)
  169. {
  170. a1 *= (-1);
  171. b1++;
  172. SumDr (a, b, a1, b1);
  173. }
  174. Co(a, b);
  175. return 0;
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement