Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- /* maximum number of numbers */
- #define BUF 100
- int main(int argc, char* argv[])
- {
- if (argc == 1)
- {
- printf("\nUsage: Enter positive integers as arguments.\n\n");
- exit(EXIT_FAILURE);
- }
- int i, j, num_of_nums = 0;
- unsigned int input_n, nums[BUF];
- bool repeated;
- for (i = 1; i < argc; i++)
- {
- repeated = false;
- input_n = atoi(argv[i]);
- for (j = 0; j < num_of_nums; j++)
- {
- if (input_n == nums[j])
- {
- repeated = true;
- break;
- }
- }
- if (repeated == false)
- nums[num_of_nums++] = input_n;
- }
- printf("\n");
- for (i = 0; i < num_of_nums; i++)
- printf("%d ", nums[i]);
- printf("\n\n");
- exit(EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement