موقع طلبة جامعة البحرين

يمكنك تصفح الموقع كزائر ولكن ندعوك لتسجيل عضوية خاصة بك لتحصل على كافة الصلاحيات مثل تنزيل ملفات المكتبة وقراءة تعليقات هيئة التدريس وغيرها. يمكنك الحصول على عضوية مجانية بالضغط على زر تسجيل. إذا قمت بالتسجيل مسبقا فيمكنك الضغط على زر دخول.

تسجيل دخول
  • قسم المكتبة الجامعية مغلق مؤقتا بعد الاستهداف التي تعرضت له بعض خدمات أمازون في البحرين، جاري استرجاع الملفات ونقلها إلى سيرفرات جديدة وسيتم بعدها اعادة افتتاح المكتبة

ITCS112 - ITCS104 - ITCS102 للفصل الصيفي 2014 - 2015

حد عنده جواب دي السؤال ؟

Question 4 (24 Points)
Consider the class TList given below:
class TList
{
private:
int * dynamicArr; //Pointer to a dynamic Array
int MaxSize; // Maximum Size of the dynamic array
int arrSize; // Actual Size of the dynamic array
public:
TList (int MaximumSize = 30);
void insertLast(int item) // Inserts item as the last
element in dynamicArr and increments arrSize
~ TList ();
}; // end class TList
(Part A) [6 Points]
Rewrite the above class as a template class so that it becomes a List of any type T (not just of
integers).
(Part B)[4 Points]
Write the implementation of the constructor function that initializes MaxSize to the value of
the parameter MaximumSize, initializes ArrSize to 0 and creates the
dynamic array dynamicArr of the given MaxSize.
Page 6 of 9
Question (4) Continue
(Part C)[4 Points]
Write the implementation of the destructor function.
(Part D)[6 Points]
Write the implementation of the insertLast function that receives an item of any type and
inserts it as the last element of the array dynamicArr and increments the
actual size of the array. The function should check first to
make sure that the actual size of the array will not exceed
the maximum size allowed.
(Part E)[4 Points]
1. Write a statement to define an object named myGrades of type class TList, where the
list will be of type double, and its maximum size is 50.
2. Write a statement to insert the value of 52.5 to the list myGrades defined above.
3. Write a statement to define an object named myNames of type class TList, where the
list will be of type String, and its maximum size is 20.
4. Write a statement to insert the name Ahmad to the list myNames defined above.
 
بي اي اس قيرل السؤال اللى حطيتينه موجود حله في الصفحات الى قبل
 
class TList
{
private:
int * dynamicArr; //Pointer to a dynamic Array
int MaxSize; // Maximum Size of the dynamic array
int arrSize; // Actual Size of the dynamic array
public:
TList (int MaximumSize = 30);
void insertLast(int item) // Inserts item as the last
element in dynamicArr and increments arrSize
~ TList ();
}; // end class TList

(Part B)[4 Points]
Write the implementation of the constructor function that initializes MaxSize to the value of
the parameter MaximumSize, initializes ArrSize to 0 and creates the
dynamic array dynamicArr of the given MaxSize.

(Part C)[4 Points]
Write the implementation of the destructor function.


(Part E)[4 Points]
1. Write a statement to define an object named myGrades of type class TList, where the
list will be of type double, and its maximum size is 50.
2. Write a statement to insert the value of 52.5 to the list myGrades defined above.
3. Write a statement to define an object named myNames of type class TList, where the
list will be of type String, and its maximum size is 20.
4. Write a statement to insert the name Ahmad to the list myNames defined above.


حد عنده حل دي السؤااال ؟

واهم شئ الا بالاحمر !! شلون نحله​
 
موجود فقط اجآبة البآرت الاخير ترآ مو موجود الي قبل
 
ماث لوفر اي صفحه :( ؟!!؟! تقدرين تساعديني ؟
 
PHP:
tlist <double> myGrades [50]
myGrades.insertlast[52.5]
tlist<string>mynames(20)
mynames.insertlast("ahmad")

هذي اجآبة البارت الاخير
 
^^
موجود اللى قبل بس بروحهم
لحظة بدور اي صفحة
 
شفت مال المين

بس الا فوق ماعرفت احلهم !!

مشكووورييييييييين
 
Write a program that uses a dynamic two-dimensional array marks2d to store the marks of
quizzes (double) scored by many students (rows). The program should ask the user to enter
the number of students (rows) and enter the number of quizzes (columns). Then dynamically
create the two-dimensional array marks2d of size rows X columns. The program should ask
the user to enter the marks scored by each student in each quiz and find the student with
highest average mark.
Your input/output should be as follows:
Enter the number of students: 4
Enter the number of quizzes: 6
Enter the marks scored by student #1 in 6 quizzes
10 8 9.5 7 6 7.5
Enter the marks scored by student #2 in 6 quizzes
9.5 8.5 10 10 10 10
Enter the marks scored by student #3 in 6 quizzes
7 6 5 6 7 7
Enter the marks scored by student #4 in 6 quizzes
8 9 9 8.5 9.5 8.5
The student with the highest average mark is student# 2

عرفت احله لكن آخر خطوة ما عرفت اتذكر عطونا في المقرر القبلي اشلون انطلع هايست افرج بس نسيت

ياريت أتحطين لينا الحل انجوفه
 
,ath

thnx aloooooot

:)
 
شو الفرق بين shallow copy & deap copy
؟؟
 
Consider the following class
class ArrClass
{
private:
double arr[20];
int length;
public:
ArrClass (int L=0);
void print() const;
};
Overload the operator == (equal to) as member function of the class ArrClass, so that:
A1==A2 will return true if A1 and A2 have the same length and the elements of A1 equal to
the corresponding elements of A2.
Otherwise, it returns false.

الحل
PHP:
bool Arrclass::operator==(const Arrclass& obj)const
{
	bool found=false;
	if(length==obj.length)
	{ 
		for(int i=0;i<length;i++)
		{
			if(arr[i]==obj.arr[i])
				found=true;
			else
				break;
		}
		if(found==true)
			return true;
		else
			return false;
	}
	else
		return false;
}
 
هاي الحل اتوقع انه صح


(Part B)[4 Points]
Write the implementation of the constructor function that initializes MaxSize to the value of
the parameter MaximumSize, initializes ArrSize to 0 and creates the
dynamic array dynamicArr of the given MaxSize.

template< class t>
TList :: TList (int MaximumSize = 30)
{
MaxSize= MaximumSize ;
arrSize=0;
arrSize= new t [ maxSize];
}


(Part C)[4 Points]
Write the implementation of the destructor function.

template< class t>
TList :: ~TList ()
{
maxSize=0;
arrSize = 0;
deleta [] dynamicArr;
dynamicArr = NULL;
}


good luck ^_^
 
شو الفرق بين shallow copy & deap copy
؟؟

shallow عندي بوينتر 2 مثلا : *p
*q
ثنينهم يأشروون لي ع نسخه وحده او آري واحد
deep
عندي بوينتر 2 بعد : *p
*q
كل بوينتر ليه نسخه خاصه فيه او آري خاص فيه
 
Consider the following class
class ArrClass
{
private:
double arr[20];
int length;
public:
ArrClass (int L=0);
void print() const;
};
Overload the operator == (equal to) as member function of the class ArrClass, so that:
A1==A2 will return true if A1 and A2 have the same length and the elements of A1 equal to
the corresponding elements of A2.
Otherwise, it returns false.

الحل
PHP:
bool Arrclass::operator==(const Arrclass& obj)const
{
	bool found=false;
	if(length==obj.length)
	{ 
		for(int i=0;i<length;i++)
		{
			if(arr[i]==obj.arr[i])
				found=true;
			else
				break;
		}
		if(found==true)
			return true;
		else
			return false;
	}
	else
		return false;
}

خيوو متأكده من الحل ,, لانه حليته بس مادري بعد اذا صح او لا
 
الديب كوبي يكون فيه فور لوب بس الشولو كوبي مآ يكون ؟؟
 
ايييي
تسلمي يآرب
يعطيكم العآفية
 
عودة
أعلى أسفل