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

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

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

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

ممكن احد يحل لي ذي السؤال ضروري !!
Write a function named maxPosition that takes an array of integers intList, and the
The index of the last element in the array(last). The function should return the Position (Location) of the
maximum value in the array (a number between 0 and last).
For example, if the following array intList :
​

[TD="align: left"]25 [/TD]
[TD="align: left"] 99 [/TD]
[TD="align: left"]35 [/TD]
[TD="align: left"]40 [/TD]
[TD="align: left"]45 [/TD]
[TD="align: left"]50[/TD]
[TD="align: left"] 55 [/TD]
[TD="align: left"] 888 [/TD]
[TD="align: left"] 65[/TD]
[TD="align: left"] 70[/TD]
is called with the value of last as 9 it should return 7,
but if it is called with the value of last as 6 it should return 1.

PARTD
Use the above function of part C to write a selectionsort function to sort an array of integers in
descending order (High to low).​

أظن جذي ..

كود:
#include <iostream>
using namespace std ;
int maxPosition (int list[],int last)
{
    int max=0,pos=last;
    for (int i=0;i<last;i++)
        if(list[i]>max){max=list[i];pos=i;}
    return pos;
}
void selectionsort (int list[],int size)
{
     int pos,temp;
     for (int i=0;i<size;i++)
     {
     pos=maxPosition(list,i);
     if (list[pos]<list[i]){
     temp=list[i];
     list[i]=list[pos];
     list[pos]=temp;}
     }
}
int main ()
{
    int arr[10]={25,99,35,40,45,50,55,888,65,70};
    selectionsort(arr,10);
    for(int i=0;i<10;i++)
    cout<<arr[i]<<" ";
    cout<<endl;
    system("pause");
    return 0 ; 
}
 
-

write a function "change" that takes a list of items and searches for item and change it to the new item .


هلون صح ؟!

HTML:
void change ( int list[ ] , int length , int item , int newitem )
{

for (int i=0 ; i<length ; i++ )
if (list[i]==item) newitem=item ;

}
 
-

write a function "change" that takes a list of items and searches for item and change it to the new item .


هلون صح ؟!

HTML:
void change ( int list[ ] , int length , int item , int newitem )
{

for (int i=0 ; i<length ; i++ )
if (list[i]==item) newitem=item ;

}

كلشي صح بس اهم شغله غلط
المطلوب من السؤال ندور في الlist عن رقم معين اذا حصلنا هذا الرقم نبدله بالرقم الجديد
في تحت الشرط اكتبي


PHP:
list[i]=newitem;
 

كلشي صح بس اهم شغله غلط
المطلوب من السؤال ندور في الlist عن رقم معين اذا حصلنا هذا الرقم نبدله بالرقم الجديد
في تحت الشرط اكتبي


PHP:
list[i]=newitem;


وي صح نسيته :nosweat:

مشكور
 
ممكن الحل:RpS_crying:
PART AWrite a function named outputarr that output the elements of an integer array.PART BWrite a function named readarr that reads the elements of an integer array.PART CWrite a function named maxPosition that takes an array of integers intList, and theThe index of the last element in the array(last). The function should return the Position (Location) of themaximum value in the array (a number between 0 and last).For example, if the following array intList :​
[TABLE="class: MsoTableGrid"]
[TR]
[TD="width: 59, bgcolor: transparent"]
25 ​
[/TD]
[TD="width: 59, bgcolor: transparent"]
99 ​
[/TD]
[TD="width: 59, bgcolor: transparent"]
35 ​
[/TD]
[TD="width: 59, bgcolor: transparent"]
40 ​
[/TD]
[TD="width: 59, bgcolor: transparent"]
45 ​
[/TD]
[TD="width: 59, bgcolor: transparent"]
50​
[/TD]
[TD="width: 59, bgcolor: transparent"]
55 ​
[/TD]
[TD="width: 59, bgcolor: transparent"]
888​
[/TD]
[TD="width: 59, bgcolor: transparent"]
65​
[/TD]
[TD="width: 59, bgcolor: transparent"]
70​
[/TD]
[/TR]
[/TABLE]
is called with the value of last as 9 it should return 7, but if it is called with the value of last as 6 it should return 1. PARTDUse the above function of part C to write a selectionsort function to sort an array of integers indescending order (High to low). PART FWrite a main function to test the above functions. 1. Declare an integer array named Arr with maximum size 50.2. Read 10 integers into array Arr (call function readtarr)3. Output the array before sorting( call function outputarr).4. Sort the array using function selectionsort5. Output the array after sorting( call function outputarr).​
 
-


أحد يتأكد لي اذا هذا البرنامج صح او لا اذا ما عليكم أمر

HTML:
# include <iostream>
using namespace std ; 
void sortlist ( int list[] , int size )
{
    int temp ; 
    for ( int i=1 ; i<size ; i++)
    {   for (int j=0;j<size-i;j++)
    if( list[j] > list[j+1] )
    { 
        temp=list[j];
        list[j]=list[j+1];
        list[j+1]=temp;

    }
    }
}


void readList (int array[] , int size )

{
    cout<<"Enter values : " ;
    for (int i=0;i<size ; i++)
        cin>>array[i];

}


void printList(int x[] , int size )
{ 

for (int i=0;i<size ; i++)
     cout<<x[i]<<" ";


}

int main()

{  int s[10] ; 
cout<<"Enter 10 values"<<endl;
readList (s,10);

cout<<"The values before sorting : "<<endl;
printList(s,10) ; 
cout<<"the values now are sorted : "<<endl;
sortlist (s,10);


return 0 ;


}

هذآ السؤآل


Write a C++ program that includes the following functions:
(1)A function named sortList that takes as parameters: an array of integer and the array size. The function should sort the numbers in a descending order. Use bubble sort algorithm.
(2)A function namedreadList that takes as parameters: an array of integer and the array size. The function should prompt the user to input the array data.
(3)A function named printList that takes as parameters: an array of integer and thearray size. The function should display the elements of the array.
Write a C++ program that includes the following functions:
(1)A function named sortList that takes as parameters: an array of integer and the array size. The function should sort the numbers in a descending order. Use bubble sort algorithm.
(2)A function namedreadList that takes as parameters: an array of integer and the array size. The function should prompt the user to input the array data.
(3)A function named printList that takes as parameters: an array of integer and thearray size. The function should display the elements of the array.





+

هل أحد يعرف برنامج بسيط اخف من الفيجوآل ومؤقت


:smile:
 
التعديل الأخير:
-


أحد يتأكد لي اذا هذا البرنامج صح او لا اذا ما عليكم أمر

HTML:
# include <iostream>
using namespace std ; 
void sortlist ( int list[] , int size )
{
    int temp ; 
    for ( int i=1 ; i<size ; i++)
    {   for (int j=0;j<size-i;j++)
    if( list[j] > list[j+1] )
    { 
        temp=list[j];
        list[j]=list[j+1];
        list[j+1]=temp;

    }
    }
}


void readList (int array[] , int size )

{
    cout<<"Enter values : " ;
    for (int i=0;i<size ; i++)
        cin>>array[i];

}


void printList(int x[] , int size )
{ 

for (int i=0;i<size ; i++)
     cout<<x[i]<<" ";


}

int main()

{  int s[10] ; 
cout<<"Enter 10 values"<<endl;
readList (s,10);

cout<<"The values before sorting : "<<endl;
printList(s,10) ; 
cout<<"the values now are sorted : "<<endl;
sortlist (s,10);


return 0 ;


}

هذآ السؤآل


Write a C++ program that includes the following functions:
(1)A function named sortList that takes as parameters: an array of integer and the array size. The function should sort the numbers in a descending order. Use bubble sort algorithm.
(2)A function namedreadList that takes as parameters: an array of integer and the array size. The function should prompt the user to input the array data.
(3)A function named printList that takes as parameters: an array of integer and thearray size. The function should display the elements of the array.
Write a C++ program that includes the following functions:
(1)A function named sortList that takes as parameters: an array of integer and the array size. The function should sort the numbers in a descending order. Use bubble sort algorithm.
(2)A function namedreadList that takes as parameters: an array of integer and the array size. The function should prompt the user to input the array data.
(3)A function named printList that takes as parameters: an array of integer and thearray size. The function should display the elements of the array.





+

هل أحد يعرف برنامج بسيط اخف من الفيجوآل ومؤقت


:smile:

اي صحيح

بس ضيفي اخر شي

PHP:
printList(s,10) ;

لان انتي طبعتي القيم قبل الترتيب
ورتبتينهم بس طبعتينهم بعد الترتيب


نسألكم الدعاء
 
اي صحيح

بس ضيفي اخر شي

PHP:
printList(s,10) ;

لان انتي طبعتي القيم قبل الترتيب
ورتبتينهم بس طبعتينهم بعد الترتيب


نسألكم الدعاء


مشكوور :smile2::nosweat:

في ميزآن حسنآتك يآ رب
 
آبي حل هاي السؤال مع البرنامح كامل

Write a function named SortBetween that takes an array of integers intList, index of the first element first and the index of the last element last. The function should sort the values in the array between first and last in ascending order (from low to high) (Use selection sort).
For example, if the following array intList: 0 1 2 3 4 5 6 7 8 9 ​
[TABLE="class: MsoNormalTable"]
[TR]
[TD="width: 57, bgcolor: transparent"]
25​
[/TD]
[TD="width: 57, bgcolor: transparent"]
99​
[/TD]
[TD="width: 57, bgcolor: transparent"]
85​
[/TD]
[TD="width: 57, bgcolor: transparent"]
50​
[/TD]
[TD="width: 58, bgcolor: transparent"]
45​
[/TD]
[TD="width: 58, bgcolor: transparent"]
40​
[/TD]
[TD="width: 58, bgcolor: transparent"]
55​
[/TD]
[TD="width: 58, bgcolor: transparent"]
888​
[/TD]
[TD="width: 58, bgcolor: transparent"]
65​
[/TD]
[TD="width: 58, bgcolor: transparent"]
70​
[/TD]
[/TR]
[/TABLE]
is called with the value of first as 2 and last as 8 it should return 0 1 2 3 4 5 6 7 8 9 ​
[TABLE="class: MsoNormalTable"]
[TR]
[TD="width: 57, bgcolor: transparent"]
25​
[/TD]
[TD="width: 57, bgcolor: transparent"]
99​
[/TD]
[TD="width: 57, bgcolor: transparent"]
40​
[/TD]
[TD="width: 57, bgcolor: transparent"]
45​
[/TD]
[TD="width: 58, bgcolor: transparent"]
50​
[/TD]
[TD="width: 58, bgcolor: transparent"]
55​
[/TD]
[TD="width: 58, bgcolor: transparent"]
85​
[/TD]
[TD="width: 58, bgcolor: transparent"]
65​
[/TD]
[TD="width: 58, bgcolor: transparent"]
888​
[/TD]
[TD="width: 58, bgcolor: transparent"]
70​
[/TD]
[/TR]
[/TABLE]
 
آبي حل هاي السؤال مع البرنامح كامل

Write a function named SortBetween that takes an array of integers intList, index of the first element first and the index of the last element last. The function should sort the values in the array between first and last in ascending order (from low to high) (Use selection sort).
For example, if the following array intList: 0 1 2 3 4 5 6 7 8 9 ​
[TABLE="class: MsoNormalTable"]
[TR]
[TD]
25​
[/TD]
[TD="width: 57, bgcolor: transparent"]
99​
[/TD]
[TD="width: 57, bgcolor: transparent"]
85​
[/TD]
[TD="width: 57, bgcolor: transparent"]
50​
[/TD]
[TD="width: 58, bgcolor: transparent"]
45​
[/TD]
[TD="width: 58, bgcolor: transparent"]
40​
[/TD]
[TD="width: 58, bgcolor: transparent"]
55​
[/TD]
[TD="width: 58, bgcolor: transparent"]
888​
[/TD]
[TD="width: 58, bgcolor: transparent"]
65​
[/TD]
[TD="width: 58, bgcolor: transparent"]
70​
[/TD]
[/TR]
[/TABLE]
is called with the value of first as 2 and last as 8 it should return 0 1 2 3 4 5 6 7 8 9 ​
[TABLE="class: MsoNormalTable"]
[TR]
[TD]
25​
[/TD]
[TD="width: 57, bgcolor: transparent"]
99​
[/TD]
[TD="width: 57, bgcolor: transparent"]
40​
[/TD]
[TD="width: 57, bgcolor: transparent"]
45​
[/TD]
[TD="width: 58, bgcolor: transparent"]
50​
[/TD]
[TD="width: 58, bgcolor: transparent"]
55​
[/TD]
[TD="width: 58, bgcolor: transparent"]
85​
[/TD]
[TD="width: 58, bgcolor: transparent"]
65​
[/TD]
[TD="width: 58, bgcolor: transparent"]
888​
[/TD]
[TD="width: 58, bgcolor: transparent"]
70​
[/TD]
[/TR]
[/TABLE]

هذا جاوبوه قبل
صفحه اللي قبل او اللي قبلها :blushing:
 
HTML:
#include<iostream>
using namespace std;
const int size=10;
void shifttoright(int list[],int & length,int pos)
{
	for (int i=length;i>=pos;i--)
		list[i]=list[i-1];
	length++;
	list[pos]=1;
}
void insertone(int list[],int & length,int size)
{
	int i=0;
	if (length<size)
	{
		while (i<length-2)
		{
			if (list[i]==1 && list[i+1]==0 && list[i+2]== 0 )
				shifttoright(list,length,i+3);
			i+=3;
		}
	}
	else
		cout<<"array is full"<<endl;
}
int main()
{
	int list[]={1,0,0,5,1,0,0};
	int length=7;
 
	insertone(list,length,size);
	for (int i=0;i<length;i++)
		cout<<list[i]<<" ";
	cout<<endl;
	return 0;
}
 
 
 
 
وين الغلط في الموضوع :RpS_crying: " المطلوب كتابه function تسوي insert رقم 1 بعد كل تسلسل " 100 "
 
اي موجود صفحه 22 بس الي حاط السؤال كان فيه اخطاء
 
-


يقدر أحد يحل هالسؤآل ؟!





Part (a)
Write a function named removeExtraBlanks that takes two parameters: an array of characters (Sentence), and the number of characters in the array (Length), which is passed by reference . The function should remove all extra blanks in Sentence, i.e. for each two consecutive blanks, the function should remove the second blank character and decrement length accordingly. The function should also return the number of extra blanks removed from Sentence.
For example, If Length=10 and the content of Sentence before calling the function is:
[TABLE="align: left"]
[TR]
[TD]0
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[TD]7
[/TD]
[TD]8
[/TD]
[TD]9
[/TD]
[/TR]
[TR]
[TD]‘A’
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]B
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]C
[/TD]
[TD]‘ ‘
[/TD]
[TD]D
[/TD]
[/TR]
[/TABLE]




Then, after calling the function: Length=7 and Sentence should be as follows:

[TABLE="align: left"]
[TR]
[TD]0
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[/TR]
[TR]
[TD]‘A’
[/TD]
[TD]‘ ‘
[/TD]
[TD]B
[/TD]
[TD]‘ ‘
[/TD]
[TD]C
[/TD]
[TD]‘ ‘
[/TD]
[TD]D
[/TD]
[/TR]
[/TABLE]


In addition, the function should return 3 (i.e. 3 blanks were removed)
Part (b)
Write a main program to test your function.


:nosweat:
 
HTML:
#include<iostream>
using namespace std;
const int size=10;
void shifttoright(int list[],int & length,int pos)
{
    for (int i=length;i>=pos;i--)
        list[i]=list[i-1];
    length++;
    list[pos]=1;
}
void insertone(int list[],int & length,int size)
{
    int i=0;
    if (length<size)
    {
        while (i<length-2)
        {
            if (list[i]==1 && list[i+1]==0 && list[i+2]== 0 )
                shifttoright(list,length,i+3);
            i+=3;
        }
    }
    else
        cout<<"array is full"<<endl;
}
int main()
{
    int list[]={1,0,0,5,1,0,0};
    int length=7;
 
    insertone(list,length,size);
    for (int i=0;i<length;i++)
        cout<<list[i]<<" ";
    cout<<endl;
    return 0;
}
 
 
 
 
وين الغلط في الموضوع :RpS_crying: " المطلوب كتابه function تسوي insert رقم 1 بعد كل تسلسل " 100 "

شوف الحين
عدلته ع السريع ، شوف اذا في خطأ

ولا تخلي براكت الarray فاضي
يعني بدون size

PHP:
#include<iostream>
using namespace std;
const int size=10;
void shifttoright(int list[],int & length,int pos)
{
    for (int i=length;i>=pos;i--)
        list[i]=list[i-1];
    length++;
    list[pos]=1;
}
void insertone(int list[],int & length,int size)
{
     if(length>size)
     cout<<"Array is full"<<endl;
     else {
     for(int i=0 ; i<size ; i++)
         if (list[i]==1 && list[i+1]==0 && list[i+2]== 0 )
         shifttoright(list,length,i+3);
        
      }

}
int main()
{
    int list[10]={1,0,0,1,0,0,1,0,0,0};
    int length=7;
 
    insertone(list,length,size);
    for (int i=0;i<length;i++)
        cout<<list[i]<<" ";
    cout<<endl;
    
    return 0;
}
 
-


يقدر أحد يحل هالسؤآل ؟!





Part (a)
Write a function named removeExtraBlanks that takes two parameters: an array of characters (Sentence), and the number of characters in the array (Length), which is passed by reference . The function should remove all extra blanks in Sentence, i.e. for each two consecutive blanks, the function should remove the second blank character and decrement length accordingly. The function should also return the number of extra blanks removed from Sentence.
For example, If Length=10 and the content of Sentence before calling the function is:
[TABLE="align: left"]
[TR]
[TD]0[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]‘A’[/TD]
[TD]‘ ‘[/TD]
[TD]‘ ‘[/TD]
[TD]‘ ‘[/TD]
[TD]B[/TD]
[TD]‘ ‘[/TD]
[TD]‘ ‘[/TD]
[TD]C[/TD]
[TD]‘ ‘[/TD]
[TD]D[/TD]
[/TR]
[/TABLE]




Then, after calling the function: Length=7 and Sentence should be as follows:

[TABLE="align: left"]
[TR]
[TD]0[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]‘A’[/TD]
[TD]‘ ‘[/TD]
[TD]B[/TD]
[TD]‘ ‘[/TD]
[TD]C[/TD]
[TD]‘ ‘[/TD]
[TD]D[/TD]
[/TR]
[/TABLE]


In addition, the function should return 3 (i.e. 3 blanks were removed)
Part (b)
Write a main program to test your function.


:nosweat:

انا بعد مآعرفت احله :no:
 
الاخوان مابقصرون ، المشكلة شوي مضغوط
حاولي فيه سهل ترى


حاولت بس ما خذينا على هالدرس بس خذنا فنكشن للحذف
وفيها 3 باريميتر


بس مو عآرفه كيف أخليه اذا اكثر من فراغ واحد يحذفه


ع العموم ما قصصصرت :smile:
 
انا بعد مآعرفت احله :no:

حاولت بس ما خذينا على هالدرس بس خذنا فنكشن للحذف
وفيها 3 باريميتر


بس مو عآرفه كيف أخليه اذا اكثر من فراغ واحد يحذفه


ع العموم ما قصصصرت :smile:

الحل
PHP:
#include<iostream>
using namespace std;

int removeExtraBlanks(char list[] , int &length )
{ int loc , count=0 ;
    for(int i=0 ; i<length ; i++){
    if(list[i]==' ' && list[i+1]==' '){
    loc=i;
    for(int j=loc ; j<length-1 ; j++)
    list[j]=list[j+1];
    length--;
    i--;
    count++;
    }
}
  return count;
}
int main()
{
    char arr[15]={'A',' ',' ','R',' ','T',' ',' ','G','H',' ',' ','F','F'};
    int len=14 , c ;
   c=removeExtraBlanks(arr,len);
   
   for(int i=0 ; i<len ; i++)
    cout<<arr[i];
    cout<<endl;
    
    cout<<"Counter = "<<c<<endl;
    
    system("pause");
    return 0;
    }

اذا في خطأ لاسمح الله خبروني
 
شوف الحين
عدلته ع السريع ، شوف اذا في خطأ

ولا تخلي براكت الarray فاضي
يعني بدون size

PHP:
#include<iostream>
using namespace std;
const int size=10;
void shifttoright(int list[],int & length,int pos)
{
    for (int i=length;i>=pos;i--)
        list[i]=list[i-1];
    length++;
    list[pos]=1;
}
void insertone(int list[],int & length,int size)
{
     if(length>size)
     cout<<"Array is full"<<endl;
     else {
     for(int i=0 ; i<size ; i++)
         if (list[i]==1 && list[i+1]==0 && list[i+2]== 0 )
         shifttoright(list,length,i+3);
        
      }

}
int main()
{
    int list[10]={1,0,0,1,0,0,1,0,0,0};
    int length=7;
 
    insertone(list,length,size);
    for (int i=0;i<length;i++)
        cout<<list[i]<<" ";
    cout<<endl;
    
    return 0;
}
غلط :whistling: , عدلت في برنامجي وصار مثل ما قلت لازم احط ال size بدل ما احطه فاضي ولازم اسوي i++ بدل i+=2 :smile2:
 
عودة
أعلى أسفل