Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // кн15 лр9вр17.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <stdlib.h>
- #include <iostream>
- #include "conio.h"
- #include "time.h"
- #pragma warning(disable: 4996)
- int main()
- {
- setlocale(LC_ALL, "Russian");
- srand(time(NULL));
- float x[100], y[100], z[100];
- int m;
- float rast[100];
- float min = 10000, temp;
- int n;
- printf("Количество точек\n");
- scanf("%d", &m);
- printf("\nВведите параметр(количество точек в шарах) n\n");
- scanf("%d", &n);
- for (int i = 0; i < m; i++)
- {
- x[i] = (rand() % 100) / 10.0;
- y[i] = (rand() % 100) / 10.0;
- z[i] = (rand() % 100) / 10.0;
- }
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < m; j++)
- {
- if (i == j) rast[j] = 0;
- else rast[j] = abs(sqrt(powf((x[j] - x[i]), 2) + powf((y[j] - y[i]), 2) + powf((z[j] - z[i]), 2)));
- }
- for (int j = 0; j < m; j++)
- for (int k = 0; k < m - 1; k++)
- {
- if (rast[k] > rast[k + 1])
- {
- temp = rast[k];
- rast[k] = rast[k + 1];
- rast[k + 1] = temp;
- }
- }
- if (min > rast[n-1]) min = rast[n-1];
- }
- printf("_________________\n");
- printf("i X Y Z\n");
- printf("_________________\n");
- for (int i = 0; i < m; i++)
- printf("%d %.1f %.1f %.1f\n", i + 1, x[i], y[i], z[i]);
- printf("Радиус %.2f\n", min);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement