بحل كم سؤال من الورقه الا عطونا اياها وبجي
بخلي محاولاتي طبعا اني كأني انتبهت في بدايه الموضوع ممنوع المحاولات وهيك شيء ودخلت حق اتأكد لأن إذا مايصير اني بتغربل لأن انا ماأدخل الا اني محاوله بروحي ماأحب اعتمد غيري بشكل كلي لازم احاول..وشفت ان اوادم خالين كودات وقلت مايحتاج أسأل يعني عادي
الا مع رمزي
روحي معهد ..رمزي صراحه مأساه مادري شلون يفهمون عليه مادري
...
اول سؤال
write a function named searchForLastOccurence that taxes as parameters on last occurence of the key value in the erray and return its position in the array, OR return -1 if the value is not found in the array, the function prototype is:
int searchForlastOccurencce(int arr[],int key,int size);
PHP:#include<iostream> using namespace std; { int searchforlastOccurence (int arr[],int key,int size); { int i; for(i=0;i<size;i++) if (arr[i]==key) return i; return -1; } } void main() { int arr[100]; int key,size; cout<<"enter the number of elemnt in the arry"<<endl; cin>>size; // cout<<"enter the elemnt"endl; for(int i=0;i<size;i++) cout<<"enter the key"<<endl; cin>>key; }
int searchforlastOccurence(int arr[],int key,int size)
{
int pos=-1;
for(int i=0; i<size; i++)
{ if(arr[i]==key)
pos=i;
}
if(pos==-1)
return -1;
return pos;
}
#include<iostream>
using namespace std;
const int ARRAY_SIZE=10;
int seqSearch(const int list[], int listLength, int searchItem);
int main()
{
int intList[ARRAY_SIZE];
int number;
int index;
cout<<"Line 4:Enter"<<ARRAY_SIZE
<<"integers."<<endl;
for(index=0;index<ARRAY_SIZE;index++)
cin>>intList[index];
cout<<endl;
cout<<"Line 8:Enter the number to be"
<<"searched: ";
cin>>number;
cout<<endl;
index=seqSearch(intList,ARRAY_SIZE,number);
if(index!=-1)
cout<<"Line 13: "<<number
<<"is found at position"<<index
<<endl;
else
cout<<"Line 15: "<<number
<<"is not in the list."<<endl;
system("pause");
return 0;
}
سلااام .....
هذا المثال في الكتاب ..
PHP:#include<iostream> using namespace std; const int ARRAY_SIZE=10; int seqSearch(const int list[], int listLength, int searchItem); int main() { int intList[ARRAY_SIZE]; int number; int index; cout<<"Line 4:Enter"<<ARRAY_SIZE <<"integers."<<endl; for(index=0;index<ARRAY_SIZE;index++) cin>>intList[index]; cout<<endl; cout<<"Line 8:Enter the number to be" <<"searched: "; cin>>number; cout<<endl; index=seqSearch(intList,ARRAY_SIZE,number); if(index!=-1) cout<<"Line 13: "<<number <<"is found at position"<<index <<endl; else cout<<"Line 15: "<<number <<"is not in the list."<<endl; system("pause"); return 0; }
ابي اعرف ليش ما يستوي ليي وكله يطلع ليي ارر رغم اني كاتبته صح ..؟؟
int seqSearch ( const list [],int listlength,int searchItem)
{
int loc;
for (loc=0; loc<listlength; loc++)
if ( list[loc] == searchItem)
return loc;
return -1;
}
بكرى كويز دكتور رمزي بكون في شنو ؟؟
جبتر 10 كله ؟؟
اتوقع اول كويز يكون نفس الشي عند كل الدكاترة فما بالك بدكتور واحدوالله مادري لين نفسنه او لا
احنا الكويز يوم الاربعاء عدنه
وشكله في جبتر 10
ياريت تخبرونا شنو يابو ليكم في الكويز ادا قدمتون
احنا ويه مياده والصراحه قالت لينا الجبتر كامل....
انا يدرسني الدكتور نصر الدين حلاام للحين شرحة ممتاز .. وحليو
void insertzeros ( int arr[],int & length, int pos, int NB, const int size )
{
int i,pos,size;
if ( length < size )
{
for ( i=o; i<NB; i++)
if ( arr[i] > NB)
pos = i;
for ( i=length; i>pos; i--)
length++
arr[pos] = NB
}
هذا اسايمنت وحليته بس عندي غلط ... ياريت احد اساعدني وقولي شنو الاخطاء الى عندي
السؤال
Write a function named insertzeros that takes as parameters : an array of integers , number of elements in the array which is passed by reference , a position in the array pos , an integer NB ( the number of zeros to be inserted ) , and a constant array SIZE ( maximum size ) . The function should insert NB zeros starting from pos.
the function prototype is :
void insertzeros ( int arr [], int & length , int pos , int NB , const int SIZE );
PHP:void insertzeros ( int arr[],int & length, int pos, int NB, const int size ) { int i,pos,size; if ( length < size ) { for ( i=o; i<NB; i++) if ( arr[i] > NB) pos = i; for ( i=length; i>pos; i--) length++ arr[pos] = NB }
write a function named SORTBETWEEN that takes any arry of integers INTLIST,index of the first element FIRST and index of the last elemant LAST
the fnuction should sort the values in the arry between FIRST and LAST in decending order(from hlgh to low) use bubble sort
في احد يشرح لي شنو المطلو ب
بليز حق بكرة اسلمه
ضروري الاي يعرف شنو المطلوب
لايبخل علينا
#include<iostream>
using namespace std;
void insertSum(int arr[], int & length, const int Size)
{
const int size=15;
int pos,newitem;
if(length<size // length<0)
{
int sum;
for(int i=size-2;i<length;i++)
sum=arr[i]+arr[i+1];
if(sum<arr[i+2])
{
pos=i;
break;
}
for(int j=length-3;j>=pos;j--)
list[j+2]=list[j+1];
list[pos]=newitem;
length++;
if else
return false;
}
}
ممكن تساعدوني
عندي اشوي خلل بس ما ادري في وين
Write a function named insertSum that takes as parameters: an array of integers, number of elements in the array which is passed by reference, and a constant array size. The function should insert the sum of two consecutive elements in the array if the value of the sum is less than the value of the element after the consecutive elements when there is a place in the array to insert new element.
The function prototype is: void insertSum(int arr[], int & length, const int SIZE);
وهذا الحل الي سويته
#include<iostream>
using namespace std;
void shifttoright(int arr[],int size, int pos){
int i;
for(i=size-2;i>=pos;i--)
arr[i+1]=arr;
}
void insertSum(int arr[], int & length, const int size)
{
int i;
int sum;
sum =arr+arr[i+1];
for(i=0;i<size;i++)
if(sum<arr[i+2])
shifttoright(arr,length,i);
arr=sum;
length++;
}
int main()
{
const int size=15;
int length=10 ;
int arr[15]={2,5,20,21,30,35,80,86,110,270};
cout<<"original array"<<endl;
for(int i=0;i<size;i++)
cout<<arr<<endl;
insertSum(arr,length,size);
cout<<"after calling the function"<<endl;
for(int i=0;i<size;i++)
cout<<arr<<endl;
return 0;
}
طبعا من الفكشن الي يبغونه انه نجمع اول رقمين اذا كان مجموعهم اصغر من الي بعد نحط المجموع الجديد بدل الرقم الاكبر وهكذا الى اخر شي
ممكن تشوفون لي وين الخلل
ضروري ابغيه اليوم