Write a C program which does the following; You are given two arrays int array_A[12]; int array_B[8]; Use random number generator to fill the arrays Display the content of the arrays Ask the user for a search key and also ask for the searching method o If user choice is L or l, use Linear Search o If user choice is B or b, use Binary Search Display the index of the search key entered by the user or display the error message if the search key is not found. You should have 5 separate functions for 1. Random Number Generator 2. Displaying the arrays 3. Linear Search 4. Bubble Sort 5. Binary Searc
Given a list of integers, write a program to print the count of all possible unique combinations of numbers whose sum is equal to K.
The output should be containing the count of all unique combinations of numbers whose sum is equal to K.
Sample Input 1
2 4 6 1 3
6
Sample Output 1
3
CODE:
---------
from itertools import combinations
# Get a list of numbers from input
numbers = [int(n) for n in input().split()]
# Get K value from input
k = int(input())
# Count combinations that sum to K
count = 0
# Try combinations of all possible sizes
for i in range(1, len(numbers)+1):
# Try all combinations of size i
for c in combinations(numbers, i):
# If this combination sums to K, then increase the count
if sum(c) == k:
count += 1
# Output the count
print(count)
In the above code, using import tools like combinations.
Can you please help me to write the code without using import tools?
A sports club needs a program to manage its members. Your task is to define and test a class called
Member for this purpose.
Define the Member class using
Private data members:
Member Number, Name, Birthday.
Public Methods:
Constructor with one parameter for each data member
Access methods for each data member.
The birthday is read-only.
A method for formatted screen output of all data members.
Implement the necessary methods.
Test the new Member class by creating at least two objects with the data of your choice and calling the
methods you defined.
Add a static member called ptrBoss to the class. If no chairperson has been appointed, the pointer should
point to NULL.
Additionally, define the static access methods getBoss() and setBoss(). Use a pointer to
set and return the object in question.
Test the Member class by reading the number of an existing member, making the
member the new chairperson and displaying the chairperson using getBoss().
A company wants to offer bursary to deserving students of a class of fifty. Information available for each
student is: ID number (string 3 characters) , Name (string of 10 Characters), Date of birth (day, month,
year), marks of 6 modules; mark are between 0 and 100. A student deserves a bursary if the average of
her/his marks is equal or more than 70% and she/he does not have a mark less than 60% in any of her/his
modules.
A record contains name of a footballer, his age, number of games he has played and
the average number of goals has scored in each match. Create an array of structure to
hold records of 20 such players and then write a program to read these records.
Program would able to tell the name of player that has played maximum number of
matches, the name of youngest player and a player name who scored is lowest.
A publishing company markets both books and audiocassette versions of its works.
Create a class called publication that stores the title (a string) and price (type float) of
a publication. From this class derive two classes: book, which adds a page count (type
int); and tape, which adds a playing time in minutes (type float). Each of the three
class should have a getdata() function to get its data from the user, and a putdata()
function to display data. Also include two constants publisher name (a string) and
address (type int) in the class publication.
Write a main() program that creates an array of pointers to publication. In a loop ask
the user for data about a particular book or tape, and use new to create an object of
type book or tape to hold the data. Put the pointer to the object in the array. When the
user has finished entering the data for all books and tapes, display the resulting data for
all books and tapes entered using a loop
. If we have the structure of the student given as and suppose we have ten students
struct student
{
char name[20];
int eng;
int math;
int phys;
double mean;
};
a) We want to calculate mean of three subjects of each person.
b) We want to determine grade based on mean of three subjects and table shown in
below. Confirm by executing it.
Mean Grade
90 <= x <= 100 S
80 <= x < 90 A
70 <= x < 80 B
60 <= x < 70 C
x < 60 D
A sports club needs a program to manage its members. Your task is to define and test a class called
Member for this purpose.
Define the Member class using
Private data members:
Member Number, Name, Birthday.
Public Methods:
Constructor with one parameter for each data member
Access methods for each data member.
The birthday is read-only.
A method for formatted screen output of all data members.
Implement the necessary methods.
Test the new Member class by creating at least two objects with the data of your choice and calling the
methods you defined.
Add a static member called ptrBoss to the class. If no chairperson has been appointed, the pointer should
point to NULL.
Additionally, define the static access methods getBoss() and setBoss(). Use a pointer to
set and return the object in question.
Test the Member class by reading the number of an existing member, making the
member the new chairperson and displaying the chairperson using getBoss().
Write a menu driven program that depicts the working of a library. The menu options
should be:
1. Add book information
2. Display book information
3. List all books of given author
4. List the title of specified book
5. List the count of books in the library
6. List the books in the order of accession number
7. Exit
Create a structure called library to hold accession number, title of the book, author
name, price of the book, and flag indicating whether book is issued or not.
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the teams based on the outcome of the match.
A win earns a team 3 points. A draw earns 1. A loss earns 0.
The following information is expected:
MP: Matches Played
W: Matches Won
D: Matches Drawn (Tied)
L: Matches Lost
P: Points
The team information should be displayed in descending order of points.
sample Input:
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD;draw
output:
Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7
Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4
Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3
Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1
Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0