بنت الامارات
Active Member
- تاريخ التسجيل
- 5 نوفمبر 2011
- المشاركات
- 29
- المجموعة
- أنثى
- الدفعة الدراسية
- 2008
- الكلية
- كلية تقنية المعلومات
- التخصص
- BIS
في احد يقدر يحطلنا الحل مال بروبلم 7 توتريال 1
واكون شاكره لكم
واكون شاكره لكم


#include <iostream>
using namespace std;
int maxPosition(int list[], int size)
{
int locOfmax , max=list[0] ;
int temp , smallestindex;
for(int i=0 ; i<size ; i++)
if(list[i]>max)
{ max=list[i];
locOfmax=i;
}
for (int k=0 ; k<size-1 ; k++) //start code of sort
{
smallestindex=k;
for(int minindex=k+1 ; minindex<size ; minindex++)
if(list[minindex]<list[smallestindex])
smallestindex=minindex;
temp=list[smallestindex];
list[smallestindex]=list[k];
list[k]=temp;
} //end code of sort
return locOfmax;
}
int main()
{
int array[10]={1,2,5,7,8,9,10,45,15,20};
int r = maxPosition(array,10);
cout<<"The max. number is in index "<<r<<endl;
cout<<"Array after sotring "<<endl;
for(int j=0 ; j<10 ;j++)
cout<<array[j]<<" ";
system("pause");
return 0;
LAB ASSIGNMENTA) Define a struct called bookType that holds the following information about a book: a. Title (string),b. Price (float),c. Number of copies in stock(int).B) write a function called ReadOnebook that receives a struct bookType variable by reference and reads all the components of the variable.C) write a function called OutputOnebook that receives a struct bookType variable and outputs all the components of the variable.D) Write a function called outofstock that receives an array of struct bookType and outputs Tiles of books with 0 copies in stock . Write a main function that uses the struct bookType and tests the above functions.· Declare an array of type bookType maxsize=100 named S.· Read data of 3 books into S by calling ReadOnebook.· Output Data of each book OutputOnebook. · Output Tiles of only books with 0 copies in stock use OutputOnebook. Example of data:[TABLE="class: MsoTableGrid"]
[TR]
[TD]
Title[/TD]
[TD="width: 89, bgcolor: transparent"]
Price[/TD]
[TD="width: 273, bgcolor: transparent"]
Nb copies[/TD]
[/TR]
[TR]
[TD="width: 89, bgcolor: transparent"]
AAA[/TD]
[TD="width: 89, bgcolor: transparent"]
1[/TD]
[TD="width: 273, bgcolor: transparent"]
0[/TD]
[/TR]
[TR]
[TD="width: 89, bgcolor: transparent"]
BBB[/TD]
[TD="width: 89, bgcolor: transparent"]
0.5[/TD]
[TD="width: 273, bgcolor: transparent"]
55[/TD]
[/TR]
[TR]
[TD="width: 89, bgcolor: transparent"]
CCC[/TD]
[TD="width: 89, bgcolor: transparent"]
2.5[/TD]
[TD="width: 273, bgcolor: transparent"]
0[/TD]
[/TR]
[/TABLE]
heeeelllp 3aaaad :'''''(
#include<iostream>
#include<string>
using namespace std;
struct bookType
{
string title;
float price;
int c;
};
void ReadOnebook (bookType &book)
{
cout << "Enter Book Title: " ;
cin >> book.title;
cout << "Enter Book price: " ;
cin >> book.price;
cout << "Enter Number of copies : " ;
cin >> book.c;
cout << endl;
}
void OutputOnebook(bookType book)
{
cout << " Book Title: " << book.title;
cout << " Book price: " << book.price;
cout << " Number of copies: " << book.c;
cout << endl;
}
void outofstock (bookType book[],int num)
{
for(int i=0;i<num;i++)
if(book[i].c == 0)
cout << "Zero copies " << book[i].title << endl;
}
int main()
{
int NOB;
bookType S[100];
cout << "Enter the number of books ";
cin >> NOB;
for(int i=0;i<NOB;i++)
ReadOnebook (S[i]);
for(int i=0;i<NOB;i++)
OutputOnebook (S[i]);
outofstock(S,NOB);
return 0;
}
output will beسلام عليكم ..
طلب ضروري ضروري .. إلي في سكشن 2
دكتورة الاب أمس شرحت Assignment 2 وكتبت على سبورة تكملة جدول
Sample input/output ..وطبعاً شرح أساينمت .. لي كتب لي على سبورة
ما مداني أكتبه ..
ينزله وبكون شاكر له
PHP:#include<iostream> #include<string> using namespace std; struct bookType { string title; float price; int c; }; void ReadOnebook (bookType &book) { cout << "Enter Book Title: " ; cin >> book.title; cout << "Enter Book price: " ; cin >> book.price; cout << "Enter Number of copies : " ; cin >> book.c; cout << endl; } void OutputOnebook(bookType book) { cout << " Book Title: " << book.title; cout << " Book price: " << book.price; cout << " Number of copies: " << book.c; cout << endl; } void outofstock (bookType book[],int num) { for(int i=0;i<num;i++) if(book[i].c == 0) cout << "Zero copies " << book[i].title << endl; } int main() { int NOB; bookType S[100]; cout << "Enter the number of books "; cin >> NOB; for(int i=0;i<NOB;i++) ReadOnebook (S[i]); for(int i=0;i<NOB;i++) OutputOnebook (S[i]); outofstock(S,NOB); return 0; }
int main()
{
int NOB;
bookType S[100];
cout << "Enter the number of books ";
cin >> NOB;
if(NOB <= 100) // use this condition
{
for(int i=0;i<NOB;i++)
ReadOnebook (S[i]);
for(int i=0;i<NOB;i++)
OutputOnebook (S[i]);
outofstock(S,NOB);
}
else
cout<<"Invalid"<<endl;
system("pause");
return 0;
}

شنو فكرته هذا السؤال ممكن شرح مبسط عن فكرته
راح احاوال أسويه وشوفي شغلي بعدين
Write a function deleteAllZeros which takes an array and its length. Your function should find and delete all zeros in the arrayvoid DeleteAllZeros(int list[],int &length,int maxsize);
نفرض عندنا list فيها
5,4,7,8,9,0,1,0,4,0,4
اذا سوينا call للfunction يصبح شكلها الجديد
5,4,7,8,9,1,4,4
الZero كلهم سوينا ليهم Delete
الفكره بسيطه ، تبحث عن الزيرو ، وتسوي ال Shifting to left
ننتظر نشوف محاولتك ، حتى لو غلط خله وبنعدل لك


void deleteallzearoes(int list[], int&length)
{
for (int i=0 ; i<length ; i++ )
if(list[i]==0)
for (int j=i ; j <length ; j++)
list [j]=list[j+1];
length--;
i--
}
شوفوه اوكي
كود:void deleteallzearoes(int list[], int&length) { for (int i=0 ; i<length ; i++ ) if(list[i]==0) for (int j=i ; j <length ; j++) list [j]=list[j+1]; length--; i-- }
مو متأكد من الحل شوفوه ليي
هلي يحتاج بارت ثاني حق الفنكشن او المين ؟
#include<iostream>
#include<fstream>
void deleteallzearoes(int list[], int&length)
{
int loc;
for (int i=0 ; i<length ; i++ )
if(list[i]==0)
{
for (int j=i ; j <length ; j++)
list [j]=list[j+1];
length--;
i--;
}
}
using namespace std;
int main()
{
int list[10]={10,0,0,10,0,14,15,17,18,0};
int len=10;
deleteallzearoes(list,len);
for (int i=0 ; i<len ; i++ )
cout<<list[i]<<" ";
system("pause");
return 0;
}
اوكي الجواب ، بس عدلت انا شي بسيط بالنسبه للاقواس
وسويت لك برنامج كامل للTest
PHP:#include<iostream> #include<fstream> void deleteallzearoes(int list[], int&length) { int loc; for (int i=0 ; i<length ; i++ ) if(list[i]==0) { for (int j=i ; j <length ; j++) list [j]=list[j+1]; length--; i--; } } using namespace std; int main() { int list[10]={10,0,0,10,0,14,15,17,18,0}; int len=10; deleteallzearoes(list,len); for (int i=0 ; i<len ; i++ ) cout<<list[i]<<" "; system("pause"); return 0; }
نسألكم الدعاء

Complete the previous exercise to include the following functions:
(1) A function named computeAverage that takes as parameters: an array of double and the array size. The function should calculate and return the average of the double numbers in the array.
(2) A function named displayAboveAverage that takes as parameters: an array of double and the array size. The function should display the numbers in the array that are above the average. Hint: call computeAverage to find the average of the numbers.
(3) A function named countGrade that takes as parameters: an array of double, the array size, a double value (oldValue), and a double value (newValue). The function should replace each occurrence of the oldValue by the newValue.
double computeAverage(double list[],int length)
{
double A=0;
for(int index=0;index<length;index++)
A=A+list[index];
double Average=A/length;
return Average;
}
void displayAboveAverage(double list[],int length)
{
for(int index=0;index<length;index++)
if(list[index]>computeAverage(list,length))
cout<<list[index]<<" ";
}
void countGrade(double list[],int length,double oldValue,double newValue)
{
for(int index=0;index<length;index++)
{
if(list[index]== oldValue)
list[index]= newValue;
}
for(int index=0;index<length;index++)
cout<<list[index]<<" ";
}
int main()
{
double list[size],length , Average ,oldValue ,newValue;
int i ;
computeAverage(list,length);
displayAboveAverage(list,length);
countGrade(list,length,oldValue,newValue);
cout<<Average<<"\t";
cout<<endl;
return 0 ;
}
امم جاوبي على هالأسئلة وبتعرفين الخطأهذي main اللي سويتها
شنو الخلل اللي فيها ؟
PHP:int main() { double list[size],length , Average ,oldValue ,newValue; int i ; computeAverage(list,length); displayAboveAverage(list,length); countGrade(list,length,oldValue,newValue); cout<<Average<<"\t"; cout<<endl; return 0 ; }