-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.c
59 lines (51 loc) · 1.33 KB
/
Source.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <locale.h>
#include <time.h>
int main()
{
setlocale(LC_ALL, "ru");
double min, max, summ=0;
int n;
double Arr[10000];
int Arr1[10000];
printf("Ââåäèòå ìàññèâ èç: ");
scanf_s("%d", &n);
printf("Ââåäèòå ìèíèìàëüíûé äèàïàçîí äëÿ çíà÷åíèé ìàññèâà: ");
scanf_s("%lf", &min);
printf("Ââåäèòå ìàêñèìàëüíûé äèàïàçîí äëÿ çíà÷åíèé ìàññèâà:");
scanf_s("%lf", &max);
for (int i = 0; i < n; i++)
{
double randx = min + (rand() * (double)(max - min) / RAND_MAX);
Arr[i] = randx; // ïðèñâàèâàåì ê i-ìó ìàññèâó ðàíäîìíîå ÷èñëî â äèàïàçîíå îò min äî max
}
for (int i = 0; i < n; i++)
{
printf("Arr[%d] = %.3lf\n", i, Arr[i]); // âûâîäèì ïîëó÷èâøèéñÿ ìàññèâ èç n
}
for (int i = 0; i < n; i++)
{
summ = summ + Arr[i];
}
printf("\n Ñóììà âñåõ ÷èñåë ìàññèâà ðàâíà: %.3lf\n", summ);
for (int i = 0; i < n; i++)
{
int a; // a - äëÿ íàõîæäåíèÿ îñòàòêà, summ - ñóììà âñåõ ÷èñåë ìàññèâà
a = (Arr[i] - (int)(Arr[i]))*1000;
Arr1[i] = a;
while (Arr1[i] % 10 == 0)
Arr1[i] = Arr1[i] / 10;
for (int j = 0; j < n; j++)
{
if (i == abs(Arr1[j]))
{
summ = summ - fabs(Arr[i]);
}
}
}
printf("\n Ñóììà ÷èñåë ìàññèâà ñ ó÷åòîì âû÷åòà: %.3lf\n", summ);
return 0;
}