Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <string.h>
  4. #include <locale.h>
  5. #include <windows.h>
  6.  
  7. struct Box {
  8. int x, y, a;
  9. };
  10.  
  11. void inputDataForBox(struct Box* boxs, int N) {
  12. for (int i = 0; i < N; i++) {
  13. printf("Введите для %d квадрата координаты центра (x,y) и его длину: ", i+1);
  14. do {
  15. scanf_s("%d %d %d", &boxs[i].x, &boxs[i].y, &boxs[i].a);
  16. if (boxs[i].a <= 0) printf("Длина квадрата не может быть неположительной.\n");
  17. } while (boxs[i].a <= 0);
  18. }
  19. }
  20.  
  21. void printDataBox(struct Box* boxs, int N) {
  22. for (int i = 0; i < N; i++)
  23. printf("Квадрат N%d: координаты центра (%d, %d), длина стороны %d\n", i+1, boxs[i].x, boxs[i].y, boxs[i].a);
  24. }
  25.  
  26. int square(struct Box boxs) {
  27. return pow(boxs.a, 2);
  28. }
  29.  
  30. void main() {
  31. setlocale(LC_ALL, "rus");
  32.  
  33. struct Box* boxs;
  34. int N;
  35.  
  36. printf("Введите количество квадратов: ");
  37. scanf_s("%d", &N);
  38.  
  39. boxs = (struct Box*)malloc(N * sizeof(struct Box));
  40.  
  41. inputDataForBox(boxs, N);
  42. printDataBox(boxs, N);
  43.  
  44. getchar();
  45. getchar();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement