$30.00
Description
Files to submit: combs.s
Time it took Matthew to complete: 1.5 hours (Start early. This is a time consuming problem.)
-
All programs must compile without warnings when using the -Wall and -Werror options
-
Submit only the files requested
-
Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc
-
-
If submitting in a group on Grade Scope please make sure to mark your partner.
-
Only one of you has to submit there
-
-
Your program must match the output exactly to receive credit.
-
Make sure that all prompts and output match mine exactly.
-
Easiest way to do this is to copy and paste them
-
-
All input will be valid unless stated otherwise
-
Print all real numbers to two decimal places unless otherwise stated
-
The examples provided in the prompts do not represent all possible input you can receive.
-
All inputs in the examples in the prompt are underlined
-
You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program
-
-
If you have questions please post them on Piazza
-
Write a program called combs.s that generates all the possible combinations of a set of items of a given size.
-
-
Your program should be callable from C and have the following signature
-
int** get_combs(int* items, int k, int len)
-
-
-
-
This function should generate all possible combinations of items taken k at a time and return a 2-D array where each row contains one combination
-
The combinations should be added to the 2-D array in their natural order
-
This 2-D array should be dynamically allocated
-
As a hint you will probably need to develop a helper function that actually computes the combinations
-
-
You have been given a file called main.c that will get the inputs and call your function
-
Your function must be callable from this file
-
You will also find some helpful functions in main.c that you can call from your program
-
-
You have also been given a makefile that should compile your program. Your program MUST be able to be compiled by this makefile.
-
For those of you running 64 bit versions of Linux you may need to install the 32 bit binaries.
-
The command to install on Ubuntu is: apt-get -y install gcc-multilib
-
-
-
Examples
-
How many items do you have: 5
-
Enter your items: 1 2 3 4 5
Enter k: 3 1 2 3 1 2 4 1 2 5 1 3 4 1 3 5 1 4 5 2 3 4 2 3 5 2 4 5 3 4 5
-
-
How many items do you have: 5
-
Enter your items: 1 2 3 4 5
Enter k: 4 1234 1235 1245 1345 2345