forked from CPRO-Session1/Assignment4
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraytrim.c
More file actions
Latest commit
33 lines (28 loc) · 770 Bytes
/
Copy patharraytrim.c
File metadata and controls
33 lines (28 loc) · 770 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
/* Christopher Liu - I wasn't sure how to delete a value from an array so I just set it to zero. Sorry */
#include<stdio.h>
intmain()
{
printf("Size of array: ");
intarray_size;
scanf("%d", &array_size);
intinput_array[array_size], trimmed_array[array_size];
for (inti=0; i<array_size; i++)
{
printf("Input number at index %d: ", input_array[i]);
scanf("%d", &input_array[i]);
trimmed_array[i] =input_array[i];
}
for (inti=0; i<array_size; i++)
{
for (intj=0; j<array_size; j++)
{
printf("%d:%d i, %d:%d j\n", i, input_array[i], j, input_array[j]);
if (input_array[i] ==input_array[j] &&i!=j)
{
trimmed_array[i] =0;
}
}
printf("Value of array index %d: %d\n", i, trimmed_array[i]);
}
return0;
}