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

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

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

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

bestStudent فنكشن مثل max


اول شي بنفرض ان افضل يوزر هو الموجود في الاندكس 0


كود:
int bestIndex = 0;
عقب بسوي لوب بجيك الافرج مال السيدونت اذا حصلت طالب الافرج ماله اكبر من اللي انا فرضته بغير الفرض مالي الى الطالب اللي حصلته


كود:
for( i = 1 ... size )
{
avg1 = CalculateAvr(studentList[ i ]);
avg2 = CalculateAvr(studentList[ bestIndex ]);


if( avg1 > avg2)
bestIndex = i;
}

عقب ما يكمل اللوب المفروض عندي الاندكس الى احسن طالب بس برجعه
كود:
return bestIndex;
واذا يبون نرجع احسن طالب
كود:
return studentList [bestIndex] ;

مشكووور وااايد اخوي :blushing:
 

السلام عليكم ^^ ..
اخباركم ؟؟ !
اممممم اليوم جربت احل هالسؤال .. في جزئية ماعرفت اسويها الا هي .. شلون اعرف ان الـ list خالية عشان يعطيني مسج تقول ان خالية هالخطوة ماسويتها لان ماعرفت ..
واذا ممكن احد يجوف الكود صح لو لا .. :smile:








13205013431.jpg







كود:
void insertbeforemax(int list[] , int newitem , int&length , int size ) 
{
    int max=0 ;
    if ( length == size ) 
        cout << " no space to add item " ;
    else 
    {
        for ( int i=0; i<length ; i++ )
            if ( list[i] > max )
                max = list [i] ;

        for ( int j = length ; j>max ; j--)
            list[j] = list [ j-1];

        list [max] = newitem;
        length ++ ;
    }



​
 

السلام عليكم ^^ ..
اخباركم ؟؟ !
اممممم اليوم جربت احل هالسؤال .. في جزئية ماعرفت اسويها الا هي .. شلون اعرف ان الـ list خالية عشان يعطيني مسج تقول ان خالية هالخطوة ماسويتها لان ماعرفت ..
واذا ممكن احد يجوف الكود صح لو لا .. :smile:








13205013431.jpg







كود:
void insertbeforemax(int list[] , int newitem , int&length , int size ) 
{
    int max=0 ;
    if ( length == size ) 
        cout << " no space to add item " ;
    else 
    {
        for ( int i=0; i<length ; i++ )
            if ( list[i] > max )
                max = list [i] ;

        for ( int j = length ; j>max ; j--)
            list[j] = list [ j-1];

        list [max] = newitem;
        length ++ ;
    }



​


الكود صح ...
الجزئية اللي ما فهمتينها شلون نعرف أن الـ list خالية يعني ما فيها عناصر
احنا اللي نعرفه أن length هو عدد العناصر داخل الـ array
واذا سوينا insert داخل الـ array بنزيد الـ length
بس اذا كانت الـ array خالية يعني عدد العناصر يساوي صفر length = 0
فـ نقول عقب الـ if statement
كود:
else if ( length == 0 ) cout<<" the list is empty " ;
بس .. ما عدا ذلك الكود ما عليه كلام :msn-wink:
موفقة
= )
​
 

الكود صح ...
الجزئية اللي ما فهمتينها شلون نعرف أن الـ list خالية يعني ما فيها عناصر
احنا اللي نعرفه أن length هو عدد العناصر داخل الـ array
واذا سوينا insert داخل الـ array بنزيد الـ length
بس اذا كانت الـ array خالية يعني عدد العناصر يساوي صفر length = 0
فـ نقول عقب الـ if statement
كود:
else if ( length == 0 ) cout<<" the list is empty " ;
بس .. ما عدا ذلك الكود ما عليه كلام :msn-wink:
موفقة
= )



اهاااا جذي السالفة يعني اني جا ببالي ان لازم حركة تخلينا نعرف ان كلهم مافيهم شي وحالة خخخخخ :RpS_tongue:
مشكور خيوه ماقصرت :smile2:
​
 
ممكن احد يخبرني شنو فائدة الكونستركتر والدسركتور في لكلاس
 
ممكن احد يخبرني شنو فائدة الكونستركتر والدسركتور في لكلاس
الكونستكتور تسوي initailize الى الفاريبل الموجودين في الكلاس اول ما تعرف اوبجكت يعني مثلا لو عندك فنكشن في الكلاس تسوي

addFive() { x+=5; }
هذه الفنكشن تضيف 5 على الاكس الموجوده في الكلاس بس اول مره الاكس ما لها قيمه فالمفروض يكون فيها 0 علشان اليوزر اذا سوا كول الى هالفنكشن ما يطلع ناتج غلط اهني يجي دور الكونستكتور تقدر تحط فيها الاكس = 0

الدسركتور : هذه بروحها يصير لها كول وقت اللي البرنامج يكمل او البلوك اللي فيه الفاريبل يكمل علشان الميموري في الكمبيوتر ينحذف منها الاوبجكت اذا ما نحتاج ليه بدل ما ياخذ سبيس من الميموري
 
اممممم قاعدة احل هالسؤال هو من بارتات وصلت لبارت C وشيرت هو في بارت D بعد بس ماحطيته لان وصلت لـ c بس
وماعرفت بالضبط شلون اسويه .. وسالفة الكونستنت بالفنكشن شوي مخلتني اتوهق مادري شلون تكون وضيفتها ع الفنكشن .. ><
حليت اول بارتين .. إذا ممكن احد يجوف لي اذا في غلط و يفهمني بارت C .. :RpS_crying:





13205834261.jpg



Part A :

كود:
class Email {
private:
    string from;
    string to;
    string mb ;
    float ms;
public:
    void set(string , string , string , float);
    int getform ( string)const ;
    int getto ( string ) const ;
    int getmb ( string) const ;
    int getms ( float ) const ;
    Email () ;
    ~ Email ( );
};


Part B :

كود:
Email::Email ()
{
    from ="";
    to= "" ;
    mb = "";
    ms= 0.0 ;
}

int Email::getms( float )const 
{
    return ms ;
}



​
 
const عقب الفنكشن في الكلاس نحطها علشان نبين انا هذه الكلاس ما تغير القيمه الموجوده في الفاربيل مال الكلاس مثل print و get بس يطبعون او يرجعون الفاريبل بدون ما يغيرون

c : يبون تعرفين اوبجكت وتسوين له initialize بالقيم بس انتي حاطه كونتسكتور بدون براميتر هم يبون اللي فيها براميتر علشان تقدرين تسوين هذا بيصير جدي
كود:
Email newMsg( "IT","customer",...);
في الكلاس حطي هذا الكونستكتور
كود:
Email (string m = "",...
 
امممممممم اوكي فهمت الحركة بس شلون اني اعرف متى فيها برميتر ولا مافيها احس يخربط :RpS_crying:
​
 
امممممممم اوكي فهمت الحركة بس شلون اني اعرف متى فيها برميتر ولا مافيها احس يخربط :RpS_crying:
​

ساعات يكتبون constructor with default parameters
بس في هالسؤال مو حاطين بس لازم بيحطون لكم سؤال علشان تعرفون الاوبجكت ومنه تعرفين اذا حاطين تسون intailize الى الفاريبل في الكونستكتور يعني ما بقدر اسويها بدون ما احط ديفولت براميتر
 
اللهم صل على محمد و آل محمد

HTML:
Chap11 lab2

1. Write a definition of a struct named DateType, which includes 3 data members as follows:
The data members are:
1.     Day  with type integer
2.     Month with the type integer 
3.     Year  with the type integer 
 
2. Write a definition of a struct named SudentType, which includes data members as follows:
The data members are:
studentId: integer
Student Birthdate: DateType.
Array of marks of the max-size equal 36: double
The number of taken courses (nbc): integer 
 
 
2. Write the code for the following functions:
CalculateAvr which will calculate the average for a variable of type studentType and 
return it
.printStudent which will print the student personal information in one line, followed by all marks that he/she has been taken, ended with average

.BestStudent that receives an array of studentType and its size. The function returns the index of the best student (call function CalculateAvr).
 
3. Write a main function to test your struct .
 
Declare an array S[40] of type struct  SudentType
 
.2)    Read Personal Information of  3 students  into S 
 Output the ID of the best student (use function BestStudent)
.Print all data of the 3 students.


حليته بس مايطلع صح
شنو الخطأ في الكود ؟

كود:
# include <iostream>[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]using namespace std;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]struct DateType{[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]int Day;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]int Month;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]int Year;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]};[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]struct SudentType{[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]int studentId;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]DateType Birthdate;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]double marks[36];[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]int nbc;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]};[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]
[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]double CalculateAvr(SudentType x){[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]double sum=0;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]for (int i=0;i<x.nbc;i++)[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]sum+=x.marks[i];[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]return (sum/x.nbc);}[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]
[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]void printStudent(SudentType x){[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]cout<<x.studentId<<x.Birthdate.Day<<x.Birthdate.Month<<x.Birthdate.Year<<x.nbc;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]for (int i=0;i<x.nbc;i++)[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]cout<<x.marks[i];[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]cout<<CalculateAvr(x);}[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]
[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]int BestStudent (SudentType arr[],int size){ [/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]	int maxin=0;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]	for (int i=1;i<size;i++){[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]double ch=CalculateAvr(arr[maxin]);[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]double che=CalculateAvr(arr[i]);[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]if (ch<che)[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]maxin=i;}[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]return arr[maxin].studentId;}[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]
[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]int main (){[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]SudentType s[40];[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]for (int k=0;k<3;k++){[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]cin>>s[k].studentId>>s[k].Birthdate.Day>>s[k].Birthdate.Month>>s[k].Birthdate.Year>>s[k].nbc;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]for (int m=0;m<s[k].nbc;m++)[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]cin>>s[m].marks[m];}[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]cout<<BestStudent(s,3);[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]for (int k=0;k<3;k++){[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]printStudent(s[40]);[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]cout<<endl;}[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]return 0;[/SIZE][/COLOR][/FONT]
[FONT=comic sans ms][COLOR=#000000][SIZE=4]}

اللهم صل على محمد و آل محمد





​
 
اللهم صل على محمد و آل محمد



حليته بس مايطلع صح
شنو الخطأ في الكود ؟


​

المفروض في المين
cin>>s[m].marks[m];}
الاندكس مال الطالب المفروض k مو m


for (int k=0;k<3;k++){
printStudent(s[40]);
واهني بعد الاندكس مال s المفروض k
 
اللهم صل على محمد و آل محمد

عدلته و للحين في اخطأء في الـ Function

كود:
# include <iostream>
using namespace std;
struct DateType{
int Day;
int Month;
int Year;
};
struct SudentType{
int studentId;
DateType Birthdate;
double marks[36];
int nbc;
};


double CalculateAvr(SudentType x){
double sum=0;
for (int i=0;i<x.nbc;i++)
sum+=x.marks[i];
double avg=(sum*1.0)/x.nbc;
return avg;}


void printStudent(SudentType x){
cout<<"Student ID"<<x.studentId<<"Student BD"<<x.Birthdate.Day<<"Student BM"<<x.Birthdate.Month<<"Student BY"<<x.Birthdate.Year<<"Number of marks"<<x.nbc<<endl;
for (int i=0;i<x.nbc;i++)
cout<<x.marks[i]<<endl;
cout<<"The Average"<<CalculateAvr(x)<<endl;}


int BestStudent (SudentType arr[],int size){ 
    int maxin=0;
    for (int i=1;i<size;i++){
double ch=CalculateAvr(arr[maxin]);
double che=CalculateAvr(arr[i]);
if (ch<che)
maxin=i;}
return arr[maxin].studentId;}


int main (){
SudentType s[40];
for (int k=0;k<3;k++){
    cout<<"Enter ID";cin>>s[k].studentId;
cout<<"Enter BD";cin>>s[k].Birthdate.Day;
cout<<"Enter BM";cin>>s[k].Birthdate.Month;
cout<<"Enter MY";cin>>s[k].Birthdate.Year;
cout<<"Enter num of marks";cin>>s[k].nbc;
cout<<"Enter The marks";
for (int m=0;m<s[k].nbc;m++)
cin>>s[k].marks[k];}
cout<<"Best Student ID is"<<BestStudent(s,3)<<endl;
for (int k=0;k<3;k++){
    cout<<"Student"<<k+1<<"Info"<<endl;
printStudent(s[k]);
cout<<endl;}
return 0;
}


اللهم صل على محمد و آل محمد
​
 
اللهم صل على محمد و آل محمد

عدلته و للحين في اخطأء في الـ Function


​
الغلط لان انتي غيرتي في هذه الفور الاندكس مال الدرجات بعد وكان المفروض تغيرين بس الاندكس مال الطلاب
كود:
for (int m=0;m<s[k].nbc;m++)
[CENTER]cin>>s[k].marks[[COLOR=#ff0000]k[/COLOR]];}[/CENTER]

تصير جدي
كود:
for (int m=0;m<s[k].nbc;m++)
cin>>s[k].marks[[COLOR=#ff0000]m[/COLOR]];}
 
سلااام عليكم

طلاب سكشن 3 دكتورة نادية شنو عطوكم اليوم ؟

و هل في كويز يوم الاحد؟
 
اللهم صل على محمد و آل محمد

و عليكم السلام

يوم الأحد مافي كويز
و عطتنا الـ Constructor

اللهم صل على محمد و آل محمد
​
 
  • Like
التفاعلات: m.g.s
اللهم صل على محمد و آل محمد

و عليكم السلام

يوم الأحد مافي كويز
و عطتنا الـ Constructor

اللهم صل على محمد و آل محمد
​

ثاانكس اختي سبيل


انشيلايز او مادري شسمه خذتوه ؟
 
اللهم صل على محمد و آل محمد

هذا اللي اخذناه <<< اذا فهمت شي من هالنوت المبهدل :

https://www.uob-bh.com/upload/up_live/13209540931.jpg
https://www.uob-bh.com/upload/up_live/13209540942.jpg


اللهم صل على محمد و آل محمد


​
 
  • Like
التفاعلات: m.g.s
سلام عليكم.. مساعده ضروريه

بغيتكم اتساعدوني في هذا الاسايمنت لان مو عارفه احله نهائياَ



ITCS102_104 (Computer Programming)
SECTION #
Chap12_LAB1

1. Write a definition of a class Named PlateType for a restaurant. The class includes:
* As private member's data:
  1. It_Name(string)// Name of the It_
  2. It_Price(float)//Price of the It_
  3. It_Type(string) // offered for("Breakfast", "Lunch" or "Dinner")
* As public member's functions:
  1. SetData which set data for all data members of the object(It_Name, It_Price and It_Type).
  2. GetData which will return all data members of the object(It_Name, It_Price and It_Type).
  3. IncreasePrice which adds an amount to the It_Price of the object.
  4. showData that output data members of the object(It_Name, It_Price and It_Type) in one line.
2. Write the code to implementation the above member functions of the class PlateType.

3. Write a main function to test the class PlateType.

  1. Define an object plate1 of Type class PlateType.
  2. Set the object plate1 with the values:
  • "Baryani"
  • 3.0
  • "Lunch"
  1. Write one statement to increase the price of plate1 by 0.2BD
  2. Write one statement to output the plate1.
 
ممنوع وضع الحلول الجاهزة للاسايمنت

لأن اذا عطيناك الحل جاهز ماراح تستفيد شي

أنت حاول تحله وحط حلك وأحنا راح نعدله لك :smile2:

وبالتوفيق ان شا الله

​
 
عودة
أعلى أسفل