Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Variant 20.cpp: определяет точку входа для консольного приложения.
- // 1, 2, 4, 6, 8
- #include "StdAfx.h"
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct Dot
- {
- double x;
- double y;
- double radius;
- bool axis;
- int number;
- };
- int main()
- {
- setlocale(LC_CTYPE, "rus");
- // Переменные
- int num = 10;
- int radius = 0;
- cout << "Введите кол-во точек: ";
- cin >> num;
- Dot* st = new Dot[num];
- for (int i = 0; i < num; i++)
- {
- cout << "Введите x координату точки: ";
- cin >> st[i].x;
- cout << "Введите y координату точки: ";
- cin >> st[i].y;
- st[i].number = i+1;
- st[i].radius = sqrt((st[i].x)*(st[i].x)+(st[i].y)*(st[i].y));
- if (st[i].x == 0 || st[i].y == 0) {
- st[i].axis = true;
- }
- }
- for (int i = 0; i < num; i++)
- {
- bool was_swapped = true;
- while (was_swapped) {
- was_swapped = false;
- for (int i = 0; i < num - 1; i++) {
- if (st[i].radius > st[i+1].radius) {
- swap(st[i], st[i + 1]);
- was_swapped = true;
- }
- }
- }
- }
- cout << "================================" << endl;
- for (int i = 0; i < num; i++)
- {
- cout << "Точка номер " << st[i].number << endl;
- cout << "x: " << st[i].x << endl;
- cout << "y: " << st[i].y << endl;
- cout << "radius: " << st[i].radius << endl;
- if (st[i].axis == true) {
- cout << "Точка лежит на координатной оси " << endl;
- }
- else {
- cout << "Точка не лежит на координатной оси " << endl;
- }
- cout << "================================" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement