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
#include <stdio.h>
#include <malloc.h>
int main(void)
{
int *x, n, i, m, q=0;
printf("Enter the size of the array ");
scanf_s("%d", &n);
x = malloc(n * sizeof(int));
for (i = 0; i < n; i++)
printf("a[%d] = ", i+1);
scanf_s("%d", &x[i]);
}
for (m = 1; m > i && m <= n; m++)
if (x[i] != x[m])
q += 1;
printf("The quantity of different numbers is %d", q);
free(x);
getch();
return 0;
Объяснение:
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
#include <stdio.h>
#include <malloc.h>
int main(void)
{
int *x, n, i, m, q=0;
printf("Enter the size of the array ");
scanf_s("%d", &n);
x = malloc(n * sizeof(int));
for (i = 0; i < n; i++)
{
printf("a[%d] = ", i+1);
scanf_s("%d", &x[i]);
}
for (i = 0; i < n; i++)
{
for (m = 1; m > i && m <= n; m++)
if (x[i] != x[m])
q += 1;
}
printf("The quantity of different numbers is %d", q);
free(x);
getch();
return 0;
}
Объяснение: