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

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

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

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

بغيت مساعدة في هالاسايمنت

Part (A)
Write a function named FirstOdd that takes as parameters a pointer to an array of int, and the array size. The function should return a pointer that point to the first occurrence of odd number in the array. If no odd numbers are found, the function should return NULL. The prototype of the function is:
int * FirstOdd (int arr[], int size);
Part (B)
Write a main function to include the following
1. Write a statement(s) to declare a dynamic array of 10 integers named Arr.
2. Write a statement(s) to declare a pointer of type int named Ptr.
3. Write a statement(s) to prompt the user to enter the data of Arr.
4. Write a statement(s) to call the function FirstOdd (Arr, 10); and store the returned value in Ptr.
5. Write a statement(s) to print the value pointed by Ptr if Ptr is not NULL; otherwise output an appropriate message.​


هذا حلي اليه
وطلعت عندي الشاشة السودا لكن بعد فيه ايرور في الـ null

وهذا هو الح ـــل

#include <iostream>
using namespace std;
int FirstOdd (int arr[], int size){
for (int i=0; i<size; i++)
{if(arr/2==1)
return arr;
break;
}
return NULL;
}

int main ()
{
int Arr[10];
int *Ptr;
cout<<"Enter data";
for (int i=0; i<10; i++)
cin>>Arr;
int F = FirstOdd (Arr, 10);
if (F == NULL)
cout<<"Not found odd number";
else
cout<<F;

return 0;
}
​


Write a statement(s) to call the function FirstOdd (Arr, 10); and store the returned value in Ptr.
يبون تنادين الفنكشن والقيمة تخزنينها في الفاريبل اللي عرفتينه كبوينتر
لاحظي الفنكشن في تعريفها في السؤال ترجع لج بوينتر

داخل الفنكشن , لازم تقولين له ريترن بوينتر وليس القيمة اللي داخل الارري

في المين لما ترجع لج الفنكشن قيمة البوينتر , انتي عقب بتقولين له اطبع لي هالقيمة هذي
 
شكــراً كـــود ..

هذا تعديلي

#include <iostream>

using namespace std;
int FirstOdd (int arr[], int size){
int *p;
for (int i=0; i<size; i++)
{if(arr/2==1)
return *p;
break;
}
return NULL;
}

int main ()
{
int Arr[10];
int *Ptr;
int x;
cout<<"Enter data";
for (int i=0; i<10; i++)
cin>>Arr;
Ptr = &x;
x = FirstOdd(*Ptr, 10);
if (x == NULL)
cout<<"Not found odd number";
else
cout<<*Ptr;

return 0;
}
​
 
طفشت واحس اني قمت اهرهر بروحي لأن التمارين كلها عن الكلاس مو عن الستركجر

هذا السؤال

struct Student
{
int id;
float mark;
}
write a program that defines an array studentlist of pointer to struct student .The program should ask the user to enter student dynmically and add it to the array studentlist . the program should ask the user to enter num1 and num2 then the program should print the ids of all student thar are between num1 and num2.the maximam number of student is 100
PHP:
#include<iostream>
using namespace std;
struct student
{
int id;
float mark;
}
int main()
{
student studentlist;
int *ptr;
ptr=new int[max];
cout<<"enter the maxmam";
cin>>max;
cout<<"enter student Id";
{
for(int i=0;i<100;i++)
{
ptr[i].id;
}
 
التعديل الأخير:
غيرت الكود

هذي محاوله قولو لي صح لو غلط عشان اكمل
 
سويت تعديلات عليها

اكتفيت بالدفتر وحسيت ان اوضح
PHP:
#include<iostream>
using namespace std;
struct student
{
int id;
float mark;
}
int main()
{
student studentlist;
int *ptr;
ptr=new int[100];
 
cout<<"enter two number";
cin>>num1>>num2;
for(int i=0;i<100;i++)
{
if(ptr[i]>num1&&ptr[i]<num2)
cin>>ptr[i].id;
cout<<ptr[i].id;
}

هو افضل بس بعد

الله يستر

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

ورديت سويت تعديلات
PHP:
#include<iostream>
using namespace std;
struct student
{
int id;
float mark;
}
int main()
{
student studentlist;
//or int*studentlist;
//or student m;
//m[studentlist]=id
student *ptr;
ptr=new int[100];
ptr[studentlist]=id;
//or studentlist=new int[100]
//ptr=&studentlist; 
// 
int num1,num2;

cout<<"enter two number";
cin>>num1>>num2;
for(int i=0;i<100;i++)
{
if (studentlist[i]>num1&&studentlist[i]<num2)
cout<<"print all the student Id between "<<num1<<num2<<"\t\t"<<studentlist[i].id;
}
 
هلااا شباب

من ياخد عند مياده سكشن 11 ؟؟

شنو عطتكم اليوم ؟ ما حضرت لانه كان عندي تست 2 انج

:)
 
يا جماعة أحد يفهمنا overloading
 
من عند دكتور نصر الدين ؟!

جم رقم غرفته ؟ و اوقات فراغه ؟

ضروووري !!
 
^^^^^^^^^^^^^^^^^
في أحد يروح ليه هذا بعد
 
السلام عليكم

ممكن احد يشرح ليي جبتر 15-17 ضروري لان ماني عارفه فيه شي وعليي كويز يوم الاحد
ولا فاهمه شي ، لاني ما حضرت محاضرتين وطاف عليي اشياء واجد
 
السلام
لو سمحتون عندي اسايمنت بغيت مساعدتكم فيه
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 in the last element in dynamicArr and increments arrSize

Void print();

~ TList ();

}; // end class TList





Question1) Rewrite the above class as a template class so that it becomes a List of any type T (not just of integers).

Question2) Write the implementation of:

a. 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.

b. Destructor function

c. 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.

d. Print that output all elements of dynamicArr each element in a line.





Question3) Write A main function to test your program.

1. Write a statement to define an object named Grades_sec6 of type class TList, where the

list will be of type double, and its maximum size is 50.

2. Write the code to insert 5 grades (52.5, 45.0, 95.0, 88.5, 25.0) to the list Grades_sec6 defined above.

3. Output all grades in the list Grades_sec6

4. Write a statement to define an object named Names_sec6 of type class TList, where the

list will be of type String, and its maximum size is 20.

5. Write the code to insert 5 names( Ahmad, ali, souad, fatine, amin) to the list Names_sec6 defined above.

6. Output all names in the list Names_sec6





#include <iostream>
#include<string>
using namespace std;
template<class T>
class TList{
private:
int * dynamicArr;
int MaxSize;
int arrSize;
public:
TList (int MaximumSize = 30);
void insertLast(int item);
Void print();
~ TList ();
};
template<class T>
int TList<class T>::TList<int max>{MaxSize=max; MaximumSize=0;
dynamicArr=new;
}
int TList::~TList(){
}
template<class T>
TList<T>::~TList(){ delete[]arrSize;
}
template<class T>
void TList<class T>:: insertLast(constT&item, int pos){
if (pos>=0&&pos<MaxSize){
dynamicArr[pos]=item;
MaxSize++;
}
template<class T>
void TList<class T>::print()const( int i;
for (int i=0;i<MaxSize;i++)
cout<<dynamicArr<<"";
cout<<endl;
}
void main(){
dynamicArr<double>Grades_sec6[50];
double Grades_sec6[] {52.5, 45.0, 95.0, 88.5, 25.0 };
​


وشكرا
 
سلام ، في احد عنده نوت حق التامبلت و اوفر لودنغ وهالسوالف ،،



غبت محاضرتين ،، و طاف عليي ولا ادري وش السالفه

فهمت التامبلت بس الا قبل ما ادري وش السالفه

و كويز يوم الاحد !!
 
ممكن حل توتريال Overloaading And Templates
باجر عندي لانه كويز
 
شسالفة الجبترين الاخريين
احد يشرحهم عااد

بليز
 
ضايعين وهالنصر الدين ما يفهم

ولا يقول بعد كل محاضرة فيه كوز:RpS_crying:
 
الجبترين عن التمبلت ومادري شسمه الثانيه سهلين كلش
فيه ورقه فيها كل شي يعني مايحتاي تفتحين الكتاب
تبيني اصورها ؟
 
اكييييييييييييد مايحتاج تسال
 
صورها بسرعه باجر كوز ولا فاهم شي ولا عندي نوتات :( ..
 
عودة
أعلى أسفل