Using the following class definition of a Arraytype
class ArrayType
{
public:
void print() const; //Function to output the data stored in the array p.
void insertAtEnd(int num); //Function to insert num at the end array p
void deleteelt(int num); //Function to delete num from the array p if exist
int getsize(); //Function to return the size of array p
bool isfull(); //Function to return true if size equal to 40;
bool isEmpty(); //Function to return true if size equal to 0;
int seqsearch(int num); //Function to return the index of num or -1 if not found
Arraytype(); //default Constructor initialize length=0
private:
int length;
int p[40];
};
1) Implement all member functions of the above class.
2) Complete the following main function to test all functions of your class:
int main()
{
Arraytype L1;
int num;
cout << " Enter 5 integers." << endl;
for (int i = 0; i < 5; i++) {
cin >> num;
L1.insertAtEnd(num);
}
cout<<"your array L1 is:";
L1.print();
cout << endl;
L1.insertAtEnd(34);
cout<<"your new array L1 is:";
L1.print();
……….
return 0;
}
Using the following class definition of a Arraytype
class ArrayType
{
public:
void print() const; //Function to output the data stored in the array p.
void insertAtEnd(int num); //Function to insert num at the end array p
void deleteelt(int num); //Function to delete num from the array p if exist
int getsize(); //Function to return the size of array p
bool isfull(); //Function to return true if size equal to 40;
bool isEmpty(); //Function to return true if size equal to 0;
int seqsearch(int num); //Function to return the index of num or -1 if not found
Arraytype(); //default Constructor initialize length=0
private:
int length;
int p[40];
};
1) Implement all member functions of the above class.
2) Complete the following main function to test all functions of your class:
int main()
{
Arraytype L1;
int num;
cout << " Enter 5 integers." << endl;
for (int i = 0; i < 5; i++) {
cin >> num;
L1.insertAtEnd(num);
}
cout<<"your array L1 is:";
L1.print();
cout << endl;
L1.insertAtEnd(34);
cout<<"your new array L1 is:";
L1.print();
……….
return 0;
}
ممكن مساعدتكم لو سمحتوووا ..![]()
الكلام مخربط فوق تحت هههههههه .. عدل او سو للسؤال برنت سكرين
بس يبين سهل اللهم اول 3 فنكشنز يبيلهم عشان تفهمهم
ترى كلهم ماخذينهم قبل مافيهم ولاشئ زياده
#include <iostream>
#include <string>
using namespace std;
class ArrayType
{
private:
int length;
int p[40];
public:
void print() const;
void insertAtEnd(int num);
void deleteelt(int num);
int getsize();
bool isfull();
bool isEmpty();
int seqsearch(int num);
Arraytype();
};
void printArraytype (int p[] , int lenght)
{
for (int i=0;i<size;i++)
cout<< arraytype.p[i]<<lenght;
}
void arrayType::insertAtend(int num)
{
if(l==size)
{cout<<"array full";
}
pos=i;
for(int i=0,i<size,i++)
{ if{list[i]>=newelt)
pos=i;
break;
}
for(inti=size-1,i>=pos,i++)
list[i+1]=list[i];
list[pos]==newelt;
size++;
}
void arrayTyoe::deleteelt(int num)
{
for(int i=pos+1,i<size,i++)
list[i-1]=list[i];
size--;
}
}
int arrayType::getsize()
{
return size;
}
bool arrayType::isfull();
{
if(p[i]==40)
return true;
else return false;
}
bool arrayType::isEmpty();
{
if(p[i]==0)
return true;
else return false;
}
int arrayType:: seqsearch(int num)
{
int loc=-1;
for(int i=0,i<size,i++)
if(p[i]==key)
{loc=i;
break;
}
return loc;
}
arrayType:: Arraytype( int);
{
length=0;
}
int main()
{
Arraytype L1;
int num;
cout << " Enter 5 integers." << endl;
for (int i = 0; i < 5; i++) {
cin >> num;
L1.insertAtEnd(num);
}
cout<<"your array L1 is:";
L1.print();
cout << endl;
L1.insertAtEnd(34);
cout<<"your new array L1 is:";
L1.print();
كود:#include <iostream> #include <string> using namespace std; class ArrayType { private: int length; int p[40]; public: void print() const; void insertAtEnd(int num); void deleteelt(int num); int getsize(); bool isfull(); bool isEmpty(); int seqsearch(int num); Arraytype(); }; void printArraytype (int p[] , int lenght) { for (int i=0;i<size;i++) cout<< arraytype.p[i]<<lenght; } void arrayType::insertAtend(int num) { if(l==size) {cout<<"array full"; } pos=i; for(int i=0,i<size,i++) { if{list[i]>=newelt) pos=i; break; } for(inti=size-1,i>=pos,i++) list[i+1]=list[i]; list[pos]==newelt; size++; } void arrayTyoe::deleteelt(int num) { for(int i=pos+1,i<size,i++) list[i-1]=list[i]; size--; } } int arrayType::getsize() { return size; } bool arrayType::isfull(); { if(p[i]==40) return true; else return false; } bool arrayType::isEmpty(); { if(p[i]==0) return true; else return false; } int arrayType:: seqsearch(int num) { int loc=-1; for(int i=0,i<size,i++) if(p[i]==key) {loc=i; break; } return loc; } arrayType:: Arraytype( int); { length=0; } int main() { Arraytype L1; int num; cout << " Enter 5 integers." << endl; for (int i = 0; i < 5; i++) { cin >> num; L1.insertAtEnd(num); } cout<<"your array L1 is:"; L1.print(); cout << endl; L1.insertAtEnd(34); cout<<"your new array L1 is:"; L1.print();
هاااي اللي سسويته
PHP:Using the following class definition of a Arraytype class ArrayType { public: void print() const; //Function to output the data stored in the array p. void insertAtEnd(int num); //Function to insert num at the end array p void deleteelt(int num); //Function to delete num from the array p if exist int getsize(); //Function to return the size of array p bool isfull(); //Function to return true if size equal to 40; bool isEmpty(); //Function to return true if size equal to 0; int seqsearch(int num); //Function to return the index of num or -1 if not found Arraytype(); //default Constructor initialize length=0 private: int length; int p[40]; }; 1) Implement all member functions of the above class. 2) Complete the following main function to test all functions of your class: int main() { Arraytype L1; int num; cout << " Enter 5 integers." << endl; for (int i = 0; i < 5; i++) { cin >> num; L1.insertAtEnd(num); } cout<<"your array L1 is:"; L1.print(); cout << endl; L1.insertAtEnd(34); cout<<"your new array L1 is:"; L1.print(); ………. return 0; }
ممكن مساعدتكم لو سمحتوووا ..
void insertanitem(int arr[],int&length,int item)
{
for(int i=length ; i>length-1 ; i--)
arr[i]=arr[i-1];
length++;
arr[length-1]=item;
}
void arrsize(int arr[],int length)
{
cout<<length;
return;
}
void deleteitem(int arr[],int&length,int item)
{
for(int i=0 ; i<length ; i++)
{
if(arr[i]==item)
{
for(int j=i ; j<length-1 ; j++)
arr[j]=arr[j+1];
length--;
i--;
}
}
}
void print(int arr[],int&length)
{
for(int i=0 ; i<length ; i++)
cout<<arr[i]<<" ";
cout<<endl;
}
int seqsearch(int arr[],int length,int key)
{
for (int i=0 ; i<length ; i++)
{
if(arr[i]==key)
{
return i;
break;
}
else
return -1;
}
}
هذول جم فنكشن من المطلوبين قبل ما انام .. تفضل اخوي وسامحنا عالتقصير .. وحاول انت في الباقي + بدل الأسامي إلي انا حطيتها خلها مثل ما مكتوب في السؤال
insert item in the end of th array
PHP:void insertanitem(int arr[],int&length,int item) { for(int i=length ; i>length-1 ; i--) arr[i]=arr[i-1]; length++; arr[length-1]=item; }
Function shows the length - size of the array
PHP:void arrsize(int arr[],int length) { cout<<length; return; }
Function to Delete an item if exist
PHP:void deleteitem(int arr[],int&length,int item) { for(int i=0 ; i<length ; i++) { if(arr[i]==item) { for(int j=i ; j<length-1 ; j++) arr[j]=arr[j+1]; length--; i--; } } }
Printing Function
PHP:void print(int arr[],int&length) { for(int i=0 ; i<length ; i++) cout<<arr[i]<<" "; cout<<endl; }
Seq Seqrch
PHP:int seqsearch(int arr[],int length,int key) { for (int i=0 ; i<length ; i++) { if(arr[i]==key) { return i; break; } else return -1; } }

# include<iostream>
# include<string>
using namespace std;
class BankAccont
{
private:
long AccountNumber;
string Name;
float Balance;
public:
BankAccont(long=999,string,float=0.0);
void SetAccount(long, string, float);
void getAccount(long &, string &, float &);
void Withdeaw(float amount);
void deposite(float amount);
void displayAccontinfo();
};
BankAccont(long An, string N, float B)
{AccontNo=AN ; Name=N ; Balance=b;}
void BankAccount::SetAccount(long AccID, string NAME, float balance)
{
AccountNumber=AccID;
Name=NAME;
Balance=balance;
}
void BankAccount::getAccount(long &AccID, string &NAME, float &balance)
{
AccID=AccountNumber;
NAME=Name;
balance=Balance;
}
void BankAccont::withdraw(float amount)
{
if(Blance>=amount)
Blance=Blance-amount;
}
void BankAccont::deposite(float amount)
{
if(Blance>=amount)
Blance=Blance+amount;
}
int main()
{
float m,B;
long AN , string AccontName;
BankAccont myAccont(3/02/12,"ali",1000);
cout << "Enter amount to be drawen:";
cin >> m;
myAccont.withdraw(m);
myAccont.deopsite(300);
myAccont.displayAccontinfo;
BankAccont ITCS104Accont[50];
for(int i=0 ; i<50 ;i++)
{
cin >> AN >> AccontName >> B;
ITCS104Accont[i].setAccont(AN,AccontName,B);
return 0;
}
# include<iostream>
# include<string>
using namespace std;
class BankAccont
{
private:
long AccountNumber;
string Name;
float Balance;
public:
BankAccont(long=999,string=" ",float=0.0);
void SetAccount(long, string, float);
void getAccount(long &, string &, float &);
void Withdeaw(float amount);
void deposite(float amount);
void displayAccontinfo();
};
BankAccont :: BankAccont(long An, string N, float B)
{AccountNumber=An ; Name=N ; Balance=B;}
void BankAccont::SetAccount(long AccID, string NAME, float balance)
{
AccountNumber=AccID;
Name=NAME;
Balance=balance;
}
void BankAccont::getAccount(long &AccID, string &NAME, float &balance)
{
AccID=AccountNumber;
NAME=Name;
balance=Balance;
}
void BankAccont::Withdeaw(float amount)
{
if(Balance>=amount)
Balance=Balance-amount;
}
void BankAccont::deposite(float amount)
{
if(Balance>=amount)
Balance=Balance+amount;
}
int main()
{
float m,B;
long AN ;
string AccontName;
BankAccont myAccont(3/02/12,"ali",1000);
cout << "Enter amount to be drawen:";
cin >> m;
myAccont.Withdeaw(m);
myAccont.deposite(300);
// myAccont.displayAccontinfo(); ( you don't write implementation )
BankAccont ITCS104Accont[50];
for(int i=0 ; i<50 ;i++)
{
cin >> AN >> AccontName >> B;
ITCS104Accont[i].SetAccount(AN,AccontName,B);
}
system("pause");
return 0;
}
#include<iostream>
#include <string>
using namespace std;
class ArrayType
{
public:
void print() const; //Function to output the data stored in the array p. //by ali sec9
void insertAtEnd(int num); //Function to insert num at the end array p
void deleteelt(int num); //Function to delete num from the array p if exist
int getsize(); //Function to return the size of array p
bool isfull(); //Function to return true if size equal to 40;
bool isEmpty(); //Function to return true if size equal to 0;
int seqsearch(int num); //Function to return the index of num or -1 if not found
ArrayType(){length=0;}; //default Constructor initialize length=0
private:
int length;
int p[40];
};
int ArrayType::seqsearch(int num)
{
for (int i=0; i<length;i++)
if (p[i]==num)
return i;
return -1;
}
void ArrayType::insertAtEnd(int num){
p[length]=num;
length++;
}
void ArrayType::deleteelt(int num){
for(int i=0; i<length ; i++)
{
if(p[i] == num)
{
for (int j = i; j < length; ++j)
p[j] = p[j + 1];
length--;
}
}
}
void ArrayType::print()const
{
for (int i = 0; i < length; i++)
cout<<p[i];
}
int ArrayType::getsize(){
return length;}
bool ArrayType::isfull(){
if(getsize()==40)return true;
return false;
}
bool ArrayType::isEmpty(){
if(getsize()==0)return true;
return false;
}
int main()
{
ArrayType L1;
int num;
cout << " Enter 5 integers." << endl;
for (int i = 0; i < 5; i++) {
cin >> num;
L1.insertAtEnd(num);
}
cout<<"\n\n Your array L1 is:";
L1.print();
cout << endl;
L1.insertAtEnd(34);
L1.deleteelt(5);
cout<<"\n\n Your new array L1 is:";
L1.print();
cout <<"\n\n\n\n Your array L1 is:";
if(L1.isfull()){
cout<<"FUll\n";};
if(L1.isEmpty()){
cout<<"EMPTY\n";};
return 0;
}
#include <iostream>
using namespace std;
const double PI=3.141592;
class sparePart{
private:
double radius;
double cost;
double circumference;
double time;
double area;
public:
void set(double, double, double, double, double);
void get(double &, double &, double &, double &, double &) const;
void print();
sparePart();
~sparePart();
void ProcessTime();
void Cost();
};
void sparePart::set(double RADIUS, double CIRCUM, double COST, double TIME, double AREA)
{
radius=RADIUS;
cost=COST;
circumference=CIRCUM;
time=TIME;
area=AREA;
}
void sparePart::get(double &RADIUS, double &CIRCUM, double &COST, double &TIME, double &AREA) const
{
COST=cost;
CIRCUM=circumference;
RADIUS=radius;
TIME=time;
AREA=area;
}
void sparePart::print(){
cout<<"Cost: "<<cost<<endl
<<"Circumference: "<<circumference<<endl
<<"Radius: "<<radius<<endl
<<"Time: "<<time<<" hours."<<endl
<<"Area: "<<area<<endl;
}
sparePart::sparePart(){
cost=0.0;
circumference=0.0;
radius=0.0;
time=0.0;
area=0.0;
}
sparePart::~sparePart()
{
cout<<"Object deleted."<<endl;
}
void sparePart::ProcessTime()
{
time= (area/3) + (circumference/2);
}
void sparePart::Cost()
{
cost= 3.2 * time;
}
int main()
{
sparePart Part[10];
double COST=0.0, CIRCUM=0.0, RADIUS=0.0, TIME=0.0, AREA=0.0, SUMc=0.0, SUMt=0.0;
double gCOST=0.0, gCIRCUM=0.0, gRADIUS=0.0, gTIME=0.0, gAREA=0.0;
cout<<"Enter the info of area & circumference of 10 spare parts: "<<endl;
for(int i=0; i<10; i++)
{
cout<<"Spare #"<<i+1<<" area: ";
cin>>AREA;
cout<<"Spare #"<<i+1<<" circumference: ";
cin>>CIRCUM;
cout<<endl;
RADIUS=AREA/PI;
Part[i].set(RADIUS, CIRCUM, COST, TIME, AREA);
Part[i].ProcessTime();
Part[i].Cost();
Part[i].get(gRADIUS, gCIRCUM, gCOST, gTIME, gAREA);
SUMt += gTIME;
SUMc += gCOST;
}
cout<<"The process time is: "<<SUMt<<" hours."<<endl
<<"The cost is: "<<SUMc<<"."<<endl;
system("pause");
return 0;
}
اختي هذا الهوم اسايمت![]()
بس صيرو اذكياه وغيروو كل شي![]()
الفكرة وصلة
والكود وصل الى الدكتورة ( في طلاب يخبرون الذكاتره ) << عقول الاطفال للحين موجود![]()
