#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
int i, j;
int size;
int* values;
int min_difference;
int first_number;
int second_number;
scanf("%d", &size);
if (size > 0)
{
values = (int*)malloc(sizeof(int)* (size + 1));
for (i = 0; i < size; i++)
scanf("%d", &values[i]);
if (size > 1)
{
min_difference = abs(values[0] - values[1]);
first_number = values[0];
second_number = values[1];
for (i = 0; i < size - 1; i++)
for (j = i + 1; j < size; j++)
if (min_difference > abs(values[i] - values[j]))
{
min_difference = abs(values[i] - values[j]);
first_number = values[i];
second_number = values[j];
}
printf("%d %d\n", first_number, second_number);
}
free(values);
}
return 0;
}
Comments
Leave a comment