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

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

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

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

int recursiveMax (int a[], int first, int last){

int max=a[first];
if (max<a[first])
max=a[first]

if (first==last)
return max;
esle
recursiveMax (int a[], int first+1, int last);

}



اتوقع جدي .. مو متأكد .. مسامحة على الجواب السريع
:nosweat:

Wrong Answer
 
Write a recursive function named recursiveMin that takes three parameters, which are an array
of integers, and two integers first and last representing the beginning index and ending index of
the array.
The prototype of the function is: int recursiveMin (int a[], int first, int last);
The function should return the value of Minimum element in the array by finding a middle point
in the array call it middle. Recursively find the Min of the top half of the array, also Recursively
find the Min of the bottom half of the array, then return the Minimum of these two numbers.
Use only the recursive Minimum algorthim specified above.
No loops should be used.


ممکن مساعده فالحل :RpS_crying::RpS_crying:
 
^^
شكراً
ملاحظه : بالنسبة لسؤال التحويل
الحل صحيح 100%
 
انا حليت Tutorial الـPointer .. بخليه الليله و شوفوا لي إذا فيه اخطاء
 
ابي امتحان نهائي 2011_2012 بليزززز ضروري
 
الحل مالي فيه اخطاء شوي يبيله تعديل

المهم شباب من حل Tutorials مال الـOverloading ؟ .. ضروري شعب .. توتريالز غبي .. ماشفته جذي قبل .. الي اعرفه في الـOverloading يعطونا الـClass واحنا نسوي الـFriend Function او نخلي الـOperator داخل الـClass Public Functions !!
 
هذا حل لسؤال شفته و حاولت احله والحمد لله .. سويته .. بس ضفت عليه شغلات عشان بعدر اتعلم

الحل شوي طويل .. السؤال كان نسوي اوفرلودنج لـless than operator و لـ equal operator

PHP:
#include <iostream>
using namespace std;

class DateType
 {
     friend bool operator==(DateType&, DateType&);
private:
int  day;
int month;
int year;

public:
void setMembers(int d,int m,int y);
void printDate(){cout<<"The Date By Default Is: "<<day<<" / "<<month<<" / "<<year<<endl;};
DateType(int d=1,int m=1,int y=1900);
bool operator<(DateType&);
};

DateType::DateType(int d,int m,int y)
{
    day=d;
    month=m;
    year=y;
}

void DateType::setMembers(int d,int m,int y)
{
    day=d;
    month=m;
    year=y;
}

bool DateType::operator<(DateType&D)
{

 if(year<D.year)
 return true;

 else if(year==D.year && month<D.month)
 return true;

 else if(year==D.year && month==D.month && day<D.day)
 return true;


 else return false;

}

bool operator==(DateType&D3 , DateType&D4)
{
    if(D3.day==D4.day && D3.month==D4.month && D3.year==D4.year)
    return true;

    else return false;

}

int main()
{
    DateType D1,D2,D3,D4;
    int d;
    int m;
    int y;

   D1.printDate();

    cout<<"Enter The Day Date For operator < :";
    cin>>d;
    while(d<1 || d>31)
    {
        cout<<"Please Enter a proper day date again btw 1-31 For operator < : ";
        cin>>d;
    }

    cout<<"Enter The month Date For operator < :";
    cin>>m;
    while(m<1 || m>31)
    {
        cout<<"Please Enter a proper month date again btw 1-31 For operator < : ";
        cin>>m;
    }

    cout<<"Enter The year Date For operator < :";
    cin>>y;
    while(y<1900 || y>2020)
    {
        cout<<"Please Enter a proper year date again btw 1900-2020 For operator < : ";
        cin>>y;
    }
    D2.setMembers(d,m,y);
    cout<<endl;

    if(D2<D1)
    {
      D2.printDate();
    }

    else cout<<"The Date are not Equal!!"<<endl;

   cout<<"Enter The Day Date For operator == :";
    cin>>d;
    while(d<1 || d>31)
    {
        cout<<"Please Enter a proper day date again For operator == : ";
        cin>>d;
    }

    cout<<"Enter The month Date For operator == :";
    cin>>m;
    while(m<1 || m>31)
    {
        cout<<"Please Enter a proper month date again For operator == : ";
        cin>>m;
    }

    cout<<"Enter The year Date For operator == :";
    cin>>y;
    while(y<1900 || y>2020)
    {
        cout<<"Please Enter a proper year date again For operator == : ";
        cin>>y;
    }
    D3.setMembers(d,m,y);
    cout<<endl;

    cout<<"Enter The Day Date For operator == :";
    cin>>d;
    while(d<1 || d>31)
    {
        cout<<"Please Enter a proper day date again For operator == : ";
        cin>>d;
    }

    cout<<"Enter The month Date For operator == :";
    cin>>m;
    while(m<1 || m>31)
    {
        cout<<"Please Enter a proper month date again For operator == : ";
        cin>>m;
    }

    cout<<"Enter The year Date For operator == :";
    cin>>y;
    while(y<1900 || y>2020)
    {
        cout<<"Please Enter a proper year date again For operator == : ";
        cin>>y;
    }
    D4.setMembers(d,m,y);
    cout<<endl;

    if(D3==D4)
    {
          cout<<"Equal"<<endl;
    }

    else cout<<"Not Equal"<<endl;


    return 0;
}


اتمنى تستفيدون منه
 
السلام عليكم
بس بغيت واحد يأكد لي طريقة حذف الـ 2D dynamic arrays
هل هذي الطريقة صحيحة؟
PHP:
int **Array;
Array= new int *[5]
for(int i=0; i<5; i++)
   Array[i]=new int[2];

for(int i=0; i<5; i++)
   delete [] Array[i];

delete [] Array;
Array=NULL;
 
هذا السؤال

PHP:
Problem 4:   
a.  Define a template for a class named Frame that has two variables A and B of any type and it has the 
following functions: 
-  Constructor with two parameters to initialize both A and B. 
-  Max that return the maximum of A and B. 
-  Swap to swap the values of A and B. 
b.  Write the implementation of the functions defined in (a). 
c.  Write a main function that includes the following statements: 
-  Define an object named myFrame of type Frame. Both A and B of type integers. The initial 
value of A is 50 and the initial value of B is 30. 
-  Write a statement to print the maximum value between A and B of myFrame 
-  Write a statement to swap the value of A and B in myFrame.

وهذا الكود ناقص .. ابغيكم تشوفون لي هل هو صح الحين و شلون اعدل الأخطاء و شلون استخدمه في الـMain
PHP:
#include <iostream>
using namespace std;

template <class F>
class Frame
{
private:
    F A;
    F B;

public:
Frame(F A=0,F B=0);
F  maximum(F A,F B);
void swap(F A,F B);
void setmembers(F A,F B);

};


template<class F>
F  maximum(F A,F B)
{
    if(A>B)
    return A;

    else return B;
}

template<class F>
void swap(F A,F B)


{
    F temp;

    temp=A;
    A=B;
    B=temp;
}


int main()
{

    Frame myFrame;


    return 0;
}
 
وهذا السؤال بعد

PHP:
Problem 3:    Consider the class definition below: 
class ArrClass { 
private: 
double arr[20]; 
int length; 
public: 
ArrClass (int L=0); 
void print( ) const; 
….. 
….. 
}; 
a.  Write a statement that shows the declaration in the class ArrClass to overload the Equal operator 
(==) as a member function of the class, so that: for A1==A1, the function should return true if A1 and 
A2 have the same length and the elements of A1 equal to the corresponding elements of A2, 
otherwise the function should return false. 
b.  Write the implementation of the function defined in (a).


وهذا الحل مالي بس يطلع لي Error اول مره اشوفه
PHP:
#include <iostream>
using namespace std;

class arrclass {
private:
double arr[20];
int length;
public:
void setMembers(int L);
arrclass (int L=0);
void print( ) const;
bool operator==(arrclass&);
};


bool arrclass::operator==(arrclass&A2)
{
    if(A2.length==length)
    {
        for(int i=0 ; i<length ; i++)
        {
            if(A2.arr[i]!=arr[i])
            return false;
        }
        return true;
    }

    return false;

}

void arrclass::setMembers(int L)
{
    L=length;
}


int main()
{

    arrclass A1;
    arrclass A2;
    int L;

    cout<<"Set the length of A2: ";
    cin>>L;
    A2.setMembers(L);


    if(A2==A1);
    {
       cout<<"Equal In Length"<<endl;
    }

   else cout<<"Not Equal In Length"<<endl;

    return 0;
}


شوفوا ليي ويش هست .. تمللت وانا احاول احل في الـOverloading .. احس روحي موفاهم شي موووول من الـErrors إلي يطلعون لي !!
 
هذا السؤال

PHP:
Problem 4:   
a.  Define a template for a class named Frame that has two variables A and B of any type and it has the 
following functions: 
-  Constructor with two parameters to initialize both A and B. 
-  Max that return the maximum of A and B. 
-  Swap to swap the values of A and B. 
b.  Write the implementation of the functions defined in (a). 
c.  Write a main function that includes the following statements: 
-  Define an object named myFrame of type Frame. Both A and B of type integers. The initial 
value of A is 50 and the initial value of B is 30. 
-  Write a statement to print the maximum value between A and B of myFrame 
-  Write a statement to swap the value of A and B in myFrame.

وهذا الكود ناقص .. ابغيكم تشوفون لي هل هو صح الحين و شلون اعدل الأخطاء و شلون استخدمه في الـMain
PHP:
#include <iostream>
using namespace std;

template <class F>
class Frame
{
private:
    F A;
    F B;

public:
Frame(F A=0,F B=0);
F  maximum(F A,F B);
void swap(F A,F B);
void setmembers(F A,F B);

};


template<class F>
F  maximum(F A,F B)
{
    if(A>B)
    return A;

    else return B;
}

template<class F>
void swap(F A,F B)


{
    F temp;

    temp=A;
    A=B;
    B=temp;
}


int main()
{

    Frame myFrame;


    return 0;
}
الـTemplate هالكورس غير مطلوب + ما درسونا عنه
 
السلام عليكم جميعا
اخواني في احد يقدر يساعدتي حق دراسة المقرر
وايد صعب و انه مب فاهمه :")
على الاقل درس البونيتر
وشكرا
 
الـTemplate هالكورس غير مطلوب + ما درسونا عنه

بس الدكتوره عطتتنا سؤال واحد عن التمبليت + موجود في التوتريال !! يعني انا ادرس في الخالي !!! :RpS_crying::no::schmoll::RpS_blink:
 
بس الدكتوره عطتتنا سؤال واحد عن التمبليت + موجود في التوتريال !! يعني انا ادرس في الخالي !!! :RpS_crying::no::schmoll::RpS_blink:
دكتورة أمل غانم هي الكوردنيتور لهذا المقرر وقالت مب مطلوب، جبتر 15 مطلوب بس الـOverloading
 
دكتورة أمل غانم هي الكوردنيتور لهذا المقرر وقالت مب مطلوب، جبتر 15 مطلوب بس الـOverloading

تسلم اخوي .. خلاص ما بواصل عليه

بس عندي سؤال في هذا .. سويت بارت B .. بس موراضي يشتغل عندي ماعرف وين المشكله إذا تقدر تشوف لي وين المشكله او اي احد إذا عنده خبره في الموضوع

السؤال الخامس .. Part B

PHP:
Problem 5:    Consider the class definition below: 
class Cube { 
private: 
double x, y, z; 
public: 
….. 
}; 
For each function in part (a) and (b), include both the function prototype and the function implementation: 
a.  Overload the operator / as a non-member function, which divides the sum of  x, y, z in the first object 
by the sum of the corresponding members in the second object and return the result as double. 
b.  Overload the operator != which test if the volume of the first object is not equal to the volume of the 
second object. (Volume = x*y*z).

PHP:
#include <iostream>
using namespace std;

class Cube {
    friend bool operator!=(Cube&, Cube&);
private:
double x, y, z;
public:
Cube(double x=0.0,double y=0.0, double z=0.0);
void setmembers(double x,double y,double z);
};

void Cube::setmembers(double x,double y,double z)
{
    x=x;
    y=y;
    z=z;
}

bool Cube::operator!=(Cube&Cube1,Cube&Cube2)
{
    double Volume1;
    double Volume2;

    Volume1=Cube1.x*Cube1.y*Cube1.z;
    Volume2=Cube2.x*Cube2.y*Cube2.z;

    if(Volume1!=Volume2)
    return false;

    else return false;
}

int main()
{

    Cube Cube1,Cube2;
    double x,y,z;

    {
        {
        cout<<"Enter The Cube1 X Parameter: ";
        cin>>x;
        cout<<"Enter The Cube1 Y Parameter: ";
        cin>>y;
        cout<<"Enter The Cube1 Z Parameter: ";
        cin>>z;
        }

        Cube1.setmembers(x,y,z);
    }

    {
        {
        cout<<"Enter The Cube2 X Parameter: ";
        cin>>x;
        cout<<"Enter The Cube2 Y Parameter: ";
        cin>>y;
        cout<<"Enter The Cube2 Z Parameter: ";
        cin>>z;
        }

        Cube2.setmembers(x,y,z);
    }

    if(Cube1!=Cube2)
    cout<<"Not Equal"<<endl;

    else cout<<"Equal"<<endl;




    return 0;
}
 
^
إذا بتكتب الكود مال non-member function
ما يصير تسوي هذي الطريقة
PHP:
bool Cube::operator!=(Cube&Cube1,Cube&Cube2)
اعتبرها فنكشن عادية واكتب
PHP:
bool operator!=(Cube&Cube1,Cube&Cube2)

الطريقة اللي انت سويتها تكون حق member function بس
 
[IMGL]
#include


<iostream>


using


namespace std;


void


printReverse(int n);


int


main()


{




int num;



cout<<

"Enter a number: ";


cin>>num;


cout<<

"The number in reverse order is: ";


printReverse(num);


cout<<endl;



system(

"pause");




return 0;


}


void


printReverse(int n){




if(n==0)




return,




else if(n<0)




return;




else;


{


coue<<n%10;


printReverse(n);





}
[/IMGL]


بطبعه بالعكس ؟؟ احد يقول لي شو الايرور


Write a recursive function named reverseInput that does not take any parameter and does not


return any value. The function asks the user to enter a positive integer number each time it is


called, until zero or a negative number is input. The function then outputs the numbers entered in


reverse order. The prototype of the function is:

void reverseInput();


Example of the function Run is:


Enter positive number, (use 0 or negative to stop) :30


Enter positive number, (use 0 or negative to stop) :20


Enter positive number, (use 0 or negative to stop) :50


Enter positive number, (use 0 or negative to stop) :10


Enter positive number, (use 0 or negative to stop) :0


10


50


20


30
 
ممكن شو المطلوب من الدروس واي جباتر بالفاينيل ITCS104 واي جبتر اركز عليه ؟؟ وشكراً
 
السلام عليكم شعب ..

بس بغيت واحد يرح ليي 2 Dynamic Array

حتى لو موجود عندكم نوتات حقه ما في مشكلة​
 
عودة
أعلى أسفل