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
33 lines (28 loc) · 770 Bytes
/
arraytrim.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>
int main()
{
printf("Size of array: ");
int array_size;
scanf("%d", &array_size);
int input_array[array_size], trimmed_array[array_size];
for (int i = 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 (int i = 0; i < array_size; i++)
{
for (int j = 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]);
}
return 0;
}