ريومه الدلوعة
08-03-2007, 09:16 PM
السلام عليكم ..............
عندي برنامج سي بلس بلس بليز ساعدوني فيه .........
Write a C++ program that uses a dynamic array (i.e. use New and Delete build-in functions) to hold a list of students. Each student should have: name, ID, and age.
Your program should have the following functions:
Insert: Insert all students.
Print: Print all students.
Search: Scan through this array to find all students with particular age.
Increment: Add an integer value to each student's ID.
Important Note: Do not use the index to access array element.
n لاحظواا انه طالب الحل ب Structures:
ياليت تردون علي بدري بيليييييييييييييييييييييييييييييييز
انا حليت وهذا حلي .........
#include <iostream>
using namespace std;
typedef struct student_record {
int id;
char name;
int age;
}student;
void insert(student *ptr,int num)
{
for (int i=0;i<num;++i){
cout<<"Enter information for student"<<i+1<<":\n";
cout<<"Enter the id:\n"; cin>>ptr[i]->id;
cout<<"Enter the name:\n"; cin>>ptr[i->.name;
cout<<"Enter the age:\n"; cin>>ptr[i]->age;
}
}
void print(employee *ptr,int num)
{
cout<<"The list is:\n";
for (int i=0;i<num;++i)
{ cout<<"ID:"<<ptr[i->.id;
cout<<",Name:"<<ptr[i]->name;
cout<<"\n";
}
}
Void Search (student *ptr,int num)
{int key;
for (int i=0;i<num;++i)
if key=age
cout<<"ID:"<<ptr[i->.id;
cout<<",Name:"<<ptr[i]->name;
cout<<"\n";
}
Void in crement (student *ptr,int num)الداله هذي ماعرفتها
int main()
{
int num;
student *ptr;
cout<<"please,Enter the number of the student :\n";
cin>>num;
ptr=new student[num];
if (!ptr)
{
cout<<"Allocation Failure\n";
return 1;
}
insert(ptr,num);
print(ptr,num);
Search(ptr,num)
Increment(ptr,num)
delete [] ptr;
return 0;
}
ال main بيحتوي على سوتش كيف اوظفها
عندي برنامج سي بلس بلس بليز ساعدوني فيه .........
Write a C++ program that uses a dynamic array (i.e. use New and Delete build-in functions) to hold a list of students. Each student should have: name, ID, and age.
Your program should have the following functions:
Insert: Insert all students.
Print: Print all students.
Search: Scan through this array to find all students with particular age.
Increment: Add an integer value to each student's ID.
Important Note: Do not use the index to access array element.
n لاحظواا انه طالب الحل ب Structures:
ياليت تردون علي بدري بيليييييييييييييييييييييييييييييييز
انا حليت وهذا حلي .........
#include <iostream>
using namespace std;
typedef struct student_record {
int id;
char name;
int age;
}student;
void insert(student *ptr,int num)
{
for (int i=0;i<num;++i){
cout<<"Enter information for student"<<i+1<<":\n";
cout<<"Enter the id:\n"; cin>>ptr[i]->id;
cout<<"Enter the name:\n"; cin>>ptr[i->.name;
cout<<"Enter the age:\n"; cin>>ptr[i]->age;
}
}
void print(employee *ptr,int num)
{
cout<<"The list is:\n";
for (int i=0;i<num;++i)
{ cout<<"ID:"<<ptr[i->.id;
cout<<",Name:"<<ptr[i]->name;
cout<<"\n";
}
}
Void Search (student *ptr,int num)
{int key;
for (int i=0;i<num;++i)
if key=age
cout<<"ID:"<<ptr[i->.id;
cout<<",Name:"<<ptr[i]->name;
cout<<"\n";
}
Void in crement (student *ptr,int num)الداله هذي ماعرفتها
int main()
{
int num;
student *ptr;
cout<<"please,Enter the number of the student :\n";
cin>>num;
ptr=new student[num];
if (!ptr)
{
cout<<"Allocation Failure\n";
return 1;
}
insert(ptr,num);
print(ptr,num);
Search(ptr,num)
Increment(ptr,num)
delete [] ptr;
return 0;
}
ال main بيحتوي على سوتش كيف اوظفها