Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <string>
- #include <set>
- #include <algorithm>
- #include <utility>
- #include <iomanip>
- using namespace std;
- void task4() {
- int n;
- cin >> n;
- vector <int> x_coordinates;
- vector <int> y_coordinates;
- for (int i = 0; i < n; i++) {
- int x, y;
- cin >> x >> y;
- x_coordinates.push_back(x);
- y_coordinates.push_back(y);
- }
- int first_area = 0, second_area = 0;
- double area;
- x_coordinates.push_back(x_coordinates[0]);
- y_coordinates.push_back(y_coordinates[0]);
- for (int i = 1; i < y_coordinates.size(); i++) {
- first_area += x_coordinates[i - 1] * y_coordinates[i];
- }
- for (int i = 1; i < x_coordinates.size(); i++) {
- second_area += x_coordinates[i] * y_coordinates[i - 1];
- }
- area = (first_area - second_area) / 2;
- cout << showpoint << setprecision(2) << area;
- }
- //struct time {
- // int hours;
- // int minutes;
- // int seconds;
- // vector <int> marks;
- //};
- //
- //bool time_compare(const time& first_time, const time& second_time) {
- // if (first_time.hours != second_time.hours) {
- // return first_time.hours < second_time.hours;
- // }
- // else {
- // if (first_time.minutes != second_time.minutes) {
- // return first_time.minutes < second_time.minutes;
- // }
- // else {
- // if (first_time.seconds != second_time.seconds) {
- // return first_time.seconds < second_time.seconds;
- // }
- // }
- // }
- //}
- //
- //void task3() {
- // int n;
- // cin >> n;
- // vector <time> time_moments(n);
- // for (int i = 0; i < n; i++) {
- // time current_time;
- // int current_hours, current_minutes, current_seconds;
- // cin >> current_hours >> current_minutes >> current_seconds;
- // current_time.hours = current_hours;
- // current_time.minutes = current_minutes;
- // current_time.seconds = current_seconds;
- // time_moments[i] = current_time;
- // }
- // stable_sort(time_moments.begin(), time_moments.end(), time_compare);
- // for (auto current_time : time_moments) {
- // cout << current_time.hours << " " << current_time.minutes << " " << current_time.seconds << endl;
- // }
- //}
- void task2() {
- string number;
- cin >> number;
- set <string> current_number;
- for (int i = 0; i < number.size(); i++) {
- }
- }
- void task1() {
- int n, members_number = 0;
- cin >> n;
- vector <int> members;
- for (int i = 0; i < n; i++) {
- int current_team;
- cin >> current_team;
- members.push_back(current_team);
- members_number += current_team;
- }
- int new_members;
- cin >> new_members;
- members_number += new_members;
- bool equal_teams = false;
- if (members_number % n == 0) {
- for (auto team : members) {
- if (team == members_number / n) {
- equal_teams = true;
- cout << "NO";
- }
- }
- if (!equal_teams) {
- cout << members_number / n;
- }
- }
- else {
- cout << "NO";
- }
- }
- int main() {
- //task1();
- //task2();
- //task3();
- task4();
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement