Computer Science, asked by rachna27081998, 4 months ago

Credits
In a university, there is a certain system of credits. Each student is given a
'credit limit' which specifies the maximum credits of a subject they can take. A
student can take any number of subjects which are under his/her credit limit.
There are N students and K subjects. Each subject has a specified number of
credits. When a student chooses a subject, it becomes a (student, subject) pair
Find the maximum number of possible (subject, student) pairs for the given
credit limits and subject credit requirements.
Input Specification:
input1: K, denoting the number of subjects
input2: An array of Kelements each denoting the credits to take a
subject
input3: N, denoting the number of students
input4: An array of N elements each denoting the credit limit of a
student.​

Answers

Answered by dnishi88
68

Answer:

in python3-->

def maxcradit(input1, input2, input3, input4):

result=0

for i in input2:

if i <= input4[input3-1]:

result+=1

return result

print(maxcradit (3,[48],1,[28,32,63]))

Answered by Jamestiwari
10

class Student

{

public int CreditLimit { get; set; }

public Student(int limit)

{

CreditLimit = limit;

}

}

class Subject

{

public int MaximumCredits { get; set; }

public Subject(int limit)

{

MaximumCredits = limit;

}

}

static void Main()

{

Console.Write("Enter the number of subject: ");

int n = int.Parse(Console.ReadLine());

List<Subject> subjects = new List<Subject>();

for (int i = 0; i < n; i++)

{

Console.Write($"Enter the maximum number of credits for {i+1} subject: ");

subjects.Add(new Subject(int.Parse(Console.ReadLine())));

}

Console.Write("Enter the number of student: ");

n = int.Parse(Console.ReadLine());

List<Student> students = new List<Student>();

for (int i = 0; i < n; i++)

{

Console.Write($"Enter the credit limit for {i + 1} student: ");

students.Add(new Student(int.Parse(Console.ReadLine())));

}

MaxSubject(students, subjects);

Console.ReadKey();

}

static void MaxSubject(List<Student> students, List<Subject> subjects)

{

for (int i = 0; i < students.Count; i++)

{

int maxCount = 0;

for (int j = 0; j < subjects.Count; j++)

{

if (students[i].CreditLimit > subjects[j].MaximumCredits)

maxCount++;

}

Console.WriteLine($"For the {i + 1} student, the maximum number of subjects is {maxCount}");

}

#SPJ2

Similar questions