Skip to content

A group of kids enjoys playing a numbers game where they must identify the distinct numbers in a sequence and sort them in ascending order. This program helps them verify their answers.

Notifications You must be signed in to change notification settings

C-Coding-Assignments/Distinct-Numbers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Distinct Numbers Game 🔢

A group of kids enjoys playing a numbers game where they must identify the distinct numbers in a sequence and sort them in ascending order. This program helps them verify their answers.


Table of Contents 📖

Task 🛠️

Write a C program that finds the distinct numbers in a sequence, sorts them in ascending order, and verifies the kids' answers. The program must use specific functions as described below.


Input and Output 🖥️

Input

  • An integer n, the size of the sequence.
  • A sequence of n integers.

Output

  • The distinct numbers in ascending order, separated by spaces.

Examples 📋

Example #1

Enter the size of sequence: 8
Enter numbers: 12 25 5 25 12 8 5 12
Output: 5 8 12 25

Example #2

Enter the size of sequence: 5
Enter numbers: 12 25 5 2 8
Output: 2 5 8 12 25

Example #3

Enter the size of sequence: 5
Enter numbers: 12 12 15 12 15
Output: 12 15

Requirements ✔️

  1. The program must include the following functions:
    • int find_distinct(int numbers[], int n, int result[]);
      Finds the distinct numbers in the array numbers, stores them in result, and returns the count of distinct numbers.
    • A selection_sort function from the textbook to sort the numbers after finding the distinct elements.
  2. In the main function, call the above functions and display the result.

Usage 🚀

1. Compile the Program:

gcc -o distinct_numbers distinct_numbers.c

2. Run the Program:

./distinct_numbers

3. Input Required:

  • The size of the sequence n.
  • A sequence of n integers.

About

A group of kids enjoys playing a numbers game where they must identify the distinct numbers in a sequence and sort them in ascending order. This program helps them verify their answers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages