Update

One new tab added. Open in browser view if it is not visible. (25/08/2022 08:48)

Determining numbers

Language : C
(NOTE : Try a few times yourself before moving to the solution)


#include <stdio.h>
#include <stdbool.h>
#include <malloc.h>

int cmpfunc(const void * a, const void * b)
{
	return ((*(int *)a) - (*(int *)b));
}
int main(){
	int num;
	scanf("%d", &num);
	
	int arr[num];
	
	for(int i = 0; i < num; i++)
	{
		scanf("%d ",&arr[i]);
	}


	qsort(arr, num, sizeof(int), cmpfunc);
	int max = arr[num-1] + 1;
	//printf("max : %d\n",max);
	int freq[max];
	for(int i = 0; i < max; i++)
	freq[i] = 0;


	for(int i = 0; i < num; i++)
	{
		freq[arr[i]]++;
	}

	
	for(int i = 0; i < max; i++)
	{

		if(freq[i]==1)
		{
			printf("%d ", i);
		}
	}
	
}

No comments: