Last active
March 4, 2017 06:25
-
-
Save obiPlabon/e7b404540ee6153a75f82aea8653741e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Figure out unique numbers from an array | |
| * | |
| */ | |
| #include <stdio.h> | |
| int main() | |
| { | |
| int arr[10], arr_size; | |
| // Calculate array size dynamically | |
| arr_size = sizeof(arr) / sizeof(arr[0]); | |
| printf("Enter 10 numbers and get unique numbers among them!\n"); | |
| printf("===================================================\n"); | |
| for (int input=0; input<arr_size; input++) | |
| { | |
| scanf("%d", &arr[input]); | |
| } | |
| for (int i=0; i<arr_size; i++) | |
| { | |
| int unique = 1; // 1 for unique and zero for non | |
| for(int j=0; j<arr_size; j++) | |
| { | |
| if (arr[i] == arr[j] && i != j) { | |
| unique = 0; | |
| break; | |
| } | |
| } | |
| if (unique) | |
| printf("Unique: %d\n", arr[i]); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment