-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest111.c
More file actions
55 lines (53 loc) · 884 Bytes
/
test111.c
File metadata and controls
55 lines (53 loc) · 884 Bytes
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
#include <stdio.h>
#include <stdlib.h>
int randomInt(int n)
{
return rand()%n;
}
int main()
{
int a[10],b[10],c[10],i,j,k = 0,k_count,count_element,type = 0,newtype = 1;
srand(time(NULL));
for(i = 0; i < 10; i++)
a[i] = randomInt(11);
for(i = 0; i < 10; i++)
printf("a[%d] = %d ",i,a[i]);
printf("\n");
for(i = 0; i < 10; i++)
{
count_element = 1;
if(i != 0)
{
for (k_count = 0; k_count < k; k_count++)
{
if (a[i] == b[k_count])
{
newtype = 0;
break;
}
}
}
if (newtype != 0)
type = 0 ;
for(j = i + 1; j < 10; j++)
{
if(a[i] == a[j])
count_element++;
}
c[k] = count_element++;
if(type == 0)
{
b[k] = a[i];
k++;
type = 1;
}
newtype = 1;
}
for(i = 0; i < k; i++)
printf("b[%d] = %d ",i,b[i]);
printf("\n");
for(i = 0; i < k; i++)
printf("c[%d] = %d ",i,c[i]);
printf("\n");
return 0;
}