Advertisement
TwITe

Untitled

Sep 14th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <string>
  5. #include <set>
  6. #include <algorithm>
  7. #include <utility>
  8. #include <iomanip>
  9. using namespace std;
  10.  
  11. void task4() {
  12.     int n;
  13.     cin >> n;
  14.     vector <int> x_coordinates;
  15.     vector <int> y_coordinates;
  16.     for (int i = 0; i < n; i++) {
  17.         int x, y;
  18.         cin >> x >> y;
  19.         x_coordinates.push_back(x);
  20.         y_coordinates.push_back(y);
  21.     }
  22.     int first_area = 0, second_area = 0;
  23.     double area;
  24.     x_coordinates.push_back(x_coordinates[0]);
  25.     y_coordinates.push_back(y_coordinates[0]);
  26.     for (int i = 1; i < y_coordinates.size(); i++) {
  27.         first_area += x_coordinates[i - 1] * y_coordinates[i];
  28.     }
  29.     for (int i = 1; i < x_coordinates.size(); i++) {
  30.         second_area += x_coordinates[i] * y_coordinates[i - 1];
  31.     }
  32.     area = (first_area - second_area) / 2;
  33.     cout << showpoint << setprecision(2) << area;
  34. }
  35.  
  36. //struct time {
  37. //  int hours;
  38. //  int minutes;
  39. //  int seconds;
  40. //  vector <int> marks;
  41. //};
  42. //
  43. //bool time_compare(const time& first_time, const time& second_time) {
  44. //  if (first_time.hours != second_time.hours) {
  45. //      return first_time.hours < second_time.hours;
  46. //  }
  47. //  else {
  48. //      if (first_time.minutes != second_time.minutes) {
  49. //          return first_time.minutes < second_time.minutes;
  50. //      }
  51. //      else {
  52. //          if (first_time.seconds != second_time.seconds) {
  53. //              return first_time.seconds < second_time.seconds;
  54. //          }
  55. //      }
  56. //  }
  57. //}
  58. //
  59. //void task3() {
  60. //  int n;
  61. //  cin >> n;
  62. //  vector <time> time_moments(n);
  63. //  for (int i = 0; i < n; i++) {
  64. //      time current_time;
  65. //      int current_hours, current_minutes, current_seconds;
  66. //      cin >> current_hours >> current_minutes >> current_seconds;
  67. //      current_time.hours = current_hours;
  68. //      current_time.minutes = current_minutes;
  69. //      current_time.seconds = current_seconds;
  70. //      time_moments[i] = current_time;
  71. //  }
  72. //  stable_sort(time_moments.begin(), time_moments.end(), time_compare);
  73. //  for (auto current_time : time_moments) {
  74. //      cout << current_time.hours << " " << current_time.minutes << " " << current_time.seconds << endl;
  75. //  }
  76. //}
  77.  
  78. void task2() {
  79.     string number;
  80.     cin >> number;
  81.     set <string> current_number;
  82.     for (int i = 0; i < number.size(); i++) {
  83.  
  84.     }
  85. }
  86.  
  87. void task1() {
  88.     int n, members_number = 0;
  89.     cin >> n;
  90.     vector <int> members;
  91.     for (int i = 0; i < n; i++) {
  92.         int current_team;
  93.         cin >> current_team;
  94.         members.push_back(current_team);
  95.         members_number += current_team;
  96.     }
  97.     int new_members;
  98.     cin >> new_members;
  99.     members_number += new_members;
  100.     bool equal_teams = false;
  101.     if (members_number % n == 0) {
  102.         for (auto team : members) {
  103.             if (team == members_number / n) {
  104.                 equal_teams = true;
  105.                 cout << "NO";
  106.             }
  107.         }
  108.         if (!equal_teams) {
  109.             cout << members_number / n;
  110.         }
  111.     }
  112.     else {
  113.         cout << "NO";
  114.     }
  115. }
  116.  
  117. int main() {
  118.     //task1();
  119.     //task2();
  120.     //task3();
  121.     task4();
  122.  
  123.     system("PAUSE");
  124.     return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement