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

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

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

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

شرح وااضح ومفهوم يعطيك العافية
الله يوديك الجنة ^^
 
class StudentType
{
private:
long id;
string name;
string major;
float GPA;
string * registeredCourses;
int max_RegisteredCourses;
int number_Of_RegisteredCourses;
public:
StudentType();
StudentType(const StudentType & another);
void inputStudentdata();
char getMajor();
void display ();
~StudentType();
}


1)
Write the code of all public functions. The constructor function StudentType(const StudentType & another); is the Copy constructor that initializes the data members id, name, major, GPA, maxRegisteredCourses, number_Of_RegisteredCourses and allocates dynamically one dimensional array pointed by registeredCourses. The function should copy the content object another to the current object. Use deep copy.

2)
Write a main function that asks the user enter the maximum number of students (numstd). The program should define a dynamic array named Students of the type StudentType of size numstd. The program then should do the following:
· Input the number of students (length).
· Ask the user to enter students’ data and store them in the array Students by calling the function inputStudentdata().
· Ask the user to enter a major (CS, IS, or CE) and then print the data of all students in the array students that belong to the entered major.

ممكن الحل مع شرح ال deep copy
 
هوم وورك عطتنا اياه الدكتوره وقت الي ندرس بوينتر حليته و قلت بخليه ليكم بشوف صح او لا انا :bleh: :bleh:

PHP:
int x,*p,*q;

p=new int[4];
q=p;
*p=4;
 for (int i=0; i<3; i++)

x=*p;
p++;
*p=x+i;

for (int i=0; i<4; i++)
{cout<<*q;
q++;

}

بنشوف تعرفون للبوينتر لو ويش :RpS_lol:
​
 
^^ لا ما نعرف مخنا مقفل من دخلنا البوينتر :no: .. ياريت أحد يشرح لينا الdeep copy , shallow copy .. مادري شسالفتهم :RpS_crying:
 
^^ لا ما نعرف مخنا مقفل من دخلنا البوينتر :no: .. ياريت أحد يشرح لينا الdeep copy , shallow copy .. مادري شسالفتهم :RpS_crying:
shallow :
كود:
int *p,*q;
p=new int;
q=p;
delete p;
بعد ما نحذف " p " تختفي القيمة اللي كان يشير ليها " q "

deep :
كود:
int *p,*q;
p=new int;
q=new int;
[LEFT]q=*p*;[/LEFT]
delete p;
بعد ما نحذف " p " تبقى القيمة اللي يشير ليها " q "
 
التعديل الأخير:
هوم وورك عطتنا اياه الدكتوره وقت الي ندرس بوينتر حليته و قلت بخليه ليكم بشوف صح او لا انا :bleh: :bleh:


PHP:
int x,*p,*q;

p=new int[4];
q=p;
*p=4;
 for (int i=0; i<3; i++)

x=*p;
p++;
*p=x+i;

for (int i=0; i<4; i++)
{cout<<*q;
q++;

}

بنشوف تعرفون للبوينتر لو ويش :RpS_lol:
​
4 4 5 7​
 
  • Like
التفاعلات: 7ason
shallow :
كود:
int *p,*q;
p=new int;
q=p;
delete p;
بعد ما نحذف " p " تختفي القيمة اللي كان يشير ليها " q "

deep :
كود:
int *p,*q;
p=new int;
q=new int;
q=p;
delete p;
بعد ما نحذف " p " تبقى القيمة اللي يشير ليها " q "


طيب شلون نفرق مابينهم للآوت بوت ؟؟ يعني شكلهم على طول جذي ؟؟
 
طيب شلون نفرق مابينهم للآوت بوت ؟؟ يعني شكلهم على طول جذي ؟؟
الفرق بسيط الأول مستخدمين بوينتر واحد يشير قيمة ..
في الثاني الإثنين يشيرون لقيمة ..
 
جزاك الله خيير و سامحنة :blushing:
 
-



السلام عليكم

لو سمحتو احد يقدر يشرح لي شنو اللي في جابتر 15


operator overloading


جفت فيدوهات شرح وقريت النوت وجفت سلايدات الدكتور يوسف

بس مآ فهمت شالسآلفه !!!


ياليت احد يوضح لي بس الفكره بششكل عام :nosweat:
 
-



السلام عليكم

لو سمحتو احد يقدر يشرح لي شنو اللي في جابتر 15


operator overloading


جفت فيدوهات شرح وقريت النوت وجفت سلايدات الدكتور يوسف

بس مآ فهمت شالسآلفه !!!


ياليت احد يوضح لي بس الفكره بششكل عام :nosweat:

في البرمجة كائنية التوجه لا يمكن مقارنة كائن بكائن
إنما فقط مقارنة خاصية بخاصية
فلتفرض أن لدينا مستطيلين
يمكننا مقارنة الطول بالطول أو العرض بالعرض لكن لا يمكن مقارنة مستطيل بمستطيل آخر
و حتى العمليات الحسابية لا يمكن أن نجمع أطوالهما مثلاً
Operator Overloading أو التحميل الزائد للعملية هي ميزة تمكننا من مقارنة كائن بآخر
في حالة مثالنا السابق و باستخدام هذه الميزة يمكن أن نجمع أطوالهما و عمل المقارنات بين المستطيلين
 
جفت سلايدات الدكتور يوسف
في الحقيقة أن يوسف حراث سرق هذه الشرائح و وضع عليها اسمه
و الدليل أنه لا يعرف بعض المحتويات الموجودة
 
في البرمجة كائنية التوجه لا يمكن مقارنة كائن بكائن إنما فقط مقارنة خاصية بخاصية فلتفرض أن لدينا مستطيلين يمكننا مقارنة الطول بالطول أو العرض بالعرض لكن لا يمكن مقارنة مستطيل بمستطيل آخر و حتى العمليات الحسابية لا يمكن أن نجمع أطوالهما مثلاً Operator Overloading أو التحميل الزائد للعملية هي ميزة تمكننا من مقارنة كائن بآخر في حالة مثالنا السابق و باستخدام هذه الميزة يمكن أن نجمع أطوالهما و عمل المقارنات بين المستطيلين
اووككككي فهمت مشككور ما ققصرت
 
ممكن مساعدة في الاسايمنت

ابي احد يحل لي الاسايمنت باجر اخر يوم التسليم الساعة 11 بليس ساعدوني.
Assignment

PART(A)

Define and implement a class named Family which includes the following data members:
- memberNames: a pointer to string, representing a dynamic array to hold the names of the family members.
- age: a pointer to integer, representing a dynamic array to hold the ages of the family members.
- num: the number of family members.

The class family contains the following member functions:
​


  • [*=left]A Constructor with default value parameter for num=10. The function should create a dynamic array pointed by memberNames of size num.
    [*=left]A copy constructor.
    [*=left]A function named print to print all the member names.
    [*=left]A function named read which is used to read the members names and ages from the user and save them in the dynamic arrays.
    [*=left]A function named youngestMember that should return the name of the youngest family member.
    [*=left]A Destructor.

PART(B)

Write a main function to test your class.
​
 
حاولتين تحلين الاسايمنت؟

خلي الحل هني .. واذا فيه اخطاء بنحاول نساعدش قد ما نقدر
:rolleyes2:
​
 
Write a function named compareArraysthat takes 4parameters, two arrays of any type
(arrA[] and arrB[]) , and two integers sizeAand sizeB, being the number of elements in the two arrays respectively. The function should return boolean value which is true if the arrays are of the same size and all the corresponding elements in both arrays arrAand arrBare equal. Otherwise, it will return false. (i.e. return false if sizeAis different from sizeBor if any element of arrAis different from the corresponding element of arrB).Test the functions by writing a C++ program.


HTML:
#include <iostream>
using namespace std;
template <class T>
bool compareArrays<T>(T arrA[], T arrB[], int sizeA, int sizeB[])
{
 if(sizeA == sizeB)
 {
  for(int i=0; i<sizeA; i++)
   if(arrA[i] == arrB[i])
    return true;
 return false;
 }
 return false;
}
int main()
{
 int arrA;
 int arrB;
 int sizeA;
 int sizeB;
 cout<<"enter arrayA size"<<endl;
 cin>>sizeA;
 cout<<"enter arrayB size"<<endl;
 cin>>sizeB;
 cout<<"enter arrayA elements"<<endl;
 cin>>arrA;
 cout<<"enter arrayB elements"<<endl;
 cin>>arrB;
}

آنه حليت السؤال بس فيه اخطاء بس ماعرف شنو اهيه
ممكن مساعدتكم ضروري التسليم باجر وآنه منزله السؤال من وقت
 
التعديل الأخير:
ممكن أحد يحل لي هالأسئلة
Question1: Function: output_list
You need to create a function called output_list that will create a list of integers based on the 3 parameters: start, end and interval. The function should generate a list of numbers starting with the number start, each successive number should be closer to the number end and the numbers should all be interval apart.
[TABLE="class: MsoNormalTable, width: 6"]
[TR]
[TD="width: 295, bgcolor: transparent"]Example1:
[/TD]
[TD="width: 372, bgcolor: transparent"]Example2:
[/TD]
[/TR]
[TR]
[TD="width: 295, bgcolor: transparent"]Start=3 end=11 interval=2
The output: 3 5 7 9 11
[/TD]
[TD="width: 372, bgcolor: transparent"]Start=1 end=650 interval=100
The output: 1 101 201 301 401 501 601
[/TD]
[/TR]
[/TABLE]

Question2:
Function: sum_list
You need to create a function called sum_list that will return the sum of a list of integers based on the 3 parameters: start, endand interval.
[TABLE="class: MsoNormalTable, width: 6"]
[TR]
[TD="width: 295, bgcolor: transparent"]Example1:
[/TD]
[TD="width: 372, bgcolor: transparent"]Example2:
[/TD]
[/TR]
[TR]
[TD="width: 295, bgcolor: transparent"]Start=3 end=11 interval=2
Resul= 3+ 5 + 7+ 9+ 11
Output=The final resul is 25
[/TD]
[TD="width: 372, bgcolor: transparent"]Start=1 end=650 interval=100
Result: 1+101+ 201+ 301+401+ 501+ 601
Output: 2107
[/TD]
[/TR]
[/TABLE]

Question3:
Function: curveup_list
You need to create a function called curveup_list that will receive an a list of integers, a length and integer interval. The function should increase each element of the array list by interval..
[TABLE="class: MsoNormalTable, width: 6"]
[TR]
[TD="width: 295, bgcolor: transparent"]Example1:
[/TD]
[TD="width: 372, bgcolor: transparent"]Example2:
[/TD]
[/TR]
[TR]
[TD="width: 295, bgcolor: transparent"]List[ ] = 3 7 11 1 0
Length=5 interval=3
Resul:
List[] =6 10 14 4 3
[/TD]
[TD="width: 372, bgcolor: transparent"]List[ ] = 15 24 1 6 9 7 11 1 0 5
Length=10 interval=1
Resul:
List[] =16 24 2 7 9 7 12 2 1 6
[/TD]
[/TR]
[/TABLE]
 
ممكن أحد يحل لي هالأسئلة
Question1: Function: output_list
You need to create a function called output_list that will create a list of integers based on the 3 parameters: start, end and interval. The function should generate a list of numbers starting with the number start, each successive number should be closer to the number end and the numbers should all be interval apart.
[TABLE="class: MsoNormalTable, width: 6"]
[TR]
[TD="width: 295, bgcolor: transparent"]Example1:
[/TD]
[TD="width: 372, bgcolor: transparent"]Example2:
[/TD]
[/TR]
[TR]
[TD="width: 295, bgcolor: transparent"]Start=3 end=11 interval=2
The output: 3 5 7 9 11
[/TD]
[TD="width: 372, bgcolor: transparent"]Start=1 end=650 interval=100
The output: 1 101 201 301 401 501 601
[/TD]
[/TR]
[/TABLE]

Question2:
Function: sum_list
You need to create a function called sum_list that will return the sum of a list of integers based on the 3 parameters: start, endand interval.
[TABLE="class: MsoNormalTable, width: 6"]
[TR]
[TD="width: 295, bgcolor: transparent"]Example1:
[/TD]
[TD="width: 372, bgcolor: transparent"]Example2:
[/TD]
[/TR]
[TR]
[TD="width: 295, bgcolor: transparent"]Start=3 end=11 interval=2
Resul= 3+ 5 + 7+ 9+ 11
Output=The final resul is 25
[/TD]
[TD="width: 372, bgcolor: transparent"]Start=1 end=650 interval=100
Result: 1+101+ 201+ 301+401+ 501+ 601
Output: 2107
[/TD]
[/TR]
[/TABLE]

Question3:
Function: curveup_list
You need to create a function called curveup_list that will receive an a list of integers, a length and integer interval. The function should increase each element of the array list by interval..
[TABLE="class: MsoNormalTable, width: 6"]
[TR]
[TD="width: 295, bgcolor: transparent"]Example1:
[/TD]
[TD="width: 372, bgcolor: transparent"]Example2:
[/TD]
[/TR]
[TR]
[TD="width: 295, bgcolor: transparent"]List[ ] = 3 7 11 1 0
Length=5 interval=3
Resul:
List[] =6 10 14 4 3
[/TD]
[TD="width: 372, bgcolor: transparent"]List[ ] = 15 24 1 6 9 7 11 1 0 5
Length=10 interval=1
Resul:
List[] =16 24 2 7 9 7 12 2 1 6
[/TD]
[/TR]
[/TABLE]


This is the solution , and simple test to each function

Note : In first and second function we have
start and end
the end value should be greater than start value
We have to put condition for this

I did not do it


PHP:
#include<iostream>
using namespace std;
void output_list(int s,int e ,int i){

for(int j = s ; j <= e ; j+=i)
cout<< j << " " ; 
}

int sum_list(int s,int e ,int i){
int sum = 0 ;
for(int j = s ; j <= e ; j+=i)
sum+=j;

return sum;
}

void curveup_list(int List[] , int length , int interval){

for(int j = 0 ; j < length ; j++)
List[j]=List[j]+interval;


}
int main(){

int List[5]={10,20,2,22,8};

output_list(1,650,100);
cout<<endl<<endl;

cout<<"sum = "<<sum_list(1,650,100);
cout<<endl<<endl;

for(int j = 0 ; j < 5 ; j++)
cout<<List[j]<<" ";
cout<<endl<<endl;

curveup_list(List,5,3);
for(int j = 0 ; j < 5 ; j++)
cout<<List[j]<<" ";

cout<<endl<<endl;
system("pause");
return 0;
}
 
عودة
أعلى أسفل