Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- struct Material
- {
- double Mass;
- double Volume;
- double p;
- };
- int main()
- {
- int n;
- printf("Enter razmer\n");
- scanf_s("%d",&n);
- struct Material* k = (struct Material*)malloc(sizeof(struct Material) * n);
- for (int i = 0; i<n; i++)
- {
- while (k[i].Mass<0)
- {
- printf("Enter mass %d\n", i);
- scanf_s("%lf", &k[i].Mass);
- }
- while (k[i].Volume<0)
- {
- printf("Enter volume %d\n", i);
- scanf_s("%lf", &k[i].Volume);
- }
- k[i].p = k[i].Mass / k[i].Volume;
- }
- double min = k[0].p;
- for (int i = 0; i<n; i++)
- {
- printf("p %d=%lf\n", i, k[i].p);
- if (k[i].p<min)
- {
- min = k[i].p;
- }
- }
- printf("Min p=%lf", min);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement