Multiple Objects | Passing objects to function | Java | ISC | class 12 | Array

preview_player
Показать описание
A set is a collection in which there is no duplication of elements. S = (1, 6, 9, 24) is a set of 4 integer elements. An array of integers may be used to represent a set. You may assume that there will be a maximum of 50 elements in the set Following are some member functions of the class set
Class name: Set
Data members/instance variables: arr-an array of integers to store the elements of the set, n an integer to store the total number of elements in the set
Member functionss/methods :
Set(int nn) constructor to initialize n = nn and the array arr,
void readElements( )// reads the elements of the set,
void displayElements( ) //displays the elements of the set,
int getSize( ) //returns n, the number of elements in the set.
int has(int ele) returns 1 if ele belongs to the current set object and 0 otherwise
Set intersection(Set d) //returns the intersection of set object d and the current set object i.e., the set containing the elements that are common to both the sets .
Set unions(Set d) returns the union of set object d and the current set object i.e., the set containing the elements that are present in both the sets
Рекомендации по теме
join shbcf.ru