Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
- #include <locale.h>
- #include <windows.h>
- struct Box {
- int x, y, a;
- };
- void inputDataForBox(struct Box* boxs, int N) {
- for (int i = 0; i < N; i++) {
- printf("Введите для %d квадрата координаты центра (x,y) и его длину: ", i+1);
- do {
- scanf_s("%d %d %d", &boxs[i].x, &boxs[i].y, &boxs[i].a);
- if (boxs[i].a <= 0) printf("Длина квадрата не может быть неположительной.\n");
- } while (boxs[i].a <= 0);
- }
- }
- void printDataBox(struct Box* boxs, int N) {
- for (int i = 0; i < N; i++)
- printf("Квадрат N%d: координаты центра (%d, %d), длина стороны %d\n", i+1, boxs[i].x, boxs[i].y, boxs[i].a);
- }
- int boxContentThePoint(struct Box box, int px, int py) {
- if ((box.x - box.a <= px) && (box.x + box.a >= px) && (box.y + box.a >= py) && (box.y - box.a <= py)) return 1;
- else return 0;
- }
- int square(struct Box box) {
- return pow(box.a, 2);
- }
- void main() {
- setlocale(LC_ALL, "rus");
- struct Box* boxs;
- int N;
- printf("Введите количество квадратов: ");
- scanf_s("%d", &N);
- boxs = (struct Box*)malloc(N * sizeof(struct Box));
- inputDataForBox(boxs, N);
- printDataBox(boxs, N);
- //printf("%d", boxContentThePoint(boxs[0], 3, 3));
- getchar();
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement