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

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

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

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

ثنكس اخووي يعطيك العافية

بسوي main وبطرشه اوك
 
^^
العفو
اوكي بالأنتظار :smile:
 
ابي مساعدة في هذا البرنامج

السؤال طويل ماقدرت احطه الدكاترة يرفعون تاتوريال في البلاك بورد problem رقم 5
application of arrays

كود:
void insertaposition(int x [], int & len, int value )
{
for (int i=len ; i>pos ; i--)
x[i]=x[i-1];
lend++;
x[pos]=value;
}

// part b

void inseartseven(int x[] ,int&len, const int max)
{
for(i=0 ; i<len ; i++)
if(x[i]==x[i+]&&i+1==x[i+2])
insertapostion(x,len,i+3,7)
int main()
{
int arr[]={                               };
int len=6;
شلون تكملة البرنامج باmain
احتاج part a لانه مافهمت inseart اله عن طرق هذا الفنكشن:nosweat:
 
هل مهم الترتيب من الفنكشن الي نبدأ منها بعد ؟
 
هذا حل دكتورة امل​

PHP:
#include<iostream>
using namespace std;
void insertAtPosition(int x[],int & len,int pos, int value)
{for(int i=len;i>pos;i--)
         x[i]=x[i-1];
len++;
 x[pos]=value;
    }
void insertSeven(int x[],int & len,const int  max)
{for(int i=0;(i<len-2) && (len<max);i++)
   if(x[i]==x[i+1]&&x[i+1]==x[i+2])
      insertAtPosition(x,len,i+3,7);
     }
int main()
{
    int arr[10]={1,1,1,13,13,14};
    int len=6;
    insertSeven(arr,len,10);
    for(int i=0;i<len;i++)
       cout<<arr[i]<<"  "; 
      system("pause");return 0;}
 
هذا حل دكتورة امل​

PHP:
#include<iostream>
using namespace std;
void insertAtPosition(int x[],int & len,int pos, int value)
{for(int i=len;i>pos;i--)
         x[i]=x[i-1];
len++;
 x[pos]=value;
    }
void insertSeven(int x[],int & len,const int  max)
{for(int i=0;(i<len-2) && (len<max);i++)
   if(x[i]==x[i+1]&&x[i+1]==x[i+2])
      insertAtPosition(x,len,i+3,7);
     }
int main()
{
    int arr[10]={1,1,1,13,13,14};
    int len=6;
    insertSeven(arr,len,10);
    for(int i=0;i<len;i++)
       cout<<arr[i]<<"  "; 
      system("pause");return 0;}

شكراً اختي هذا الي كنت أقصده :msn-wink::smile:
 
هذا حل دكتورة امل​

PHP:
#include<iostream>
using namespace std;
void insertAtPosition(int x[],int & len,int pos, int value)
{for(int i=len;i>pos;i--)
         x[i]=x[i-1];
len++;
 x[pos]=value;
    }
void insertSeven(int x[],int & len,const int  max)
{for(int i=0;(i<len-2) && (len<max);i++)
   if(x[i]==x[i+1]&&x[i+1]==x[i+2])
      insertAtPosition(x,len,i+3,7);
     }
int main()
{
    int arr[10]={1,1,1,13,13,14};
    int len=6;
    insertSeven(arr,len,10);
    for(int i=0;i<len;i++)
       cout<<arr[i]<<"  "; 
      system("pause");return 0;}

بس كأنه في فنكشن قبل هذي سوت inseart حق 100
اله هي part a
 
PHP:
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;

}

PHP:
void displayAboveAverage(double list[],int length)
{
    for(int index=0;index<length;index++)
        if(list[index]>computeAverage(list,length))
            cout<<list[index]<<" ";
        
}
PHP:
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]<<" ";

}

هذي الFunctions الناقصه

اما جزء الTest أقصد اللي في الmain
هذا حاولي فيه ، عشان تستفيدين
واذا صارت صعوبات خلي الكود اللي وصلتين له وبنشوف

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



int main()
{
double list[10]={ 1.5, 2.5, 6.5,4.5,10.0, 9.5,8.2,7.0,3.5,5.5};
int length;
double Average ,oldValue ,newValue;
int A ;
computeAverage(list,length);
displayAboveAverage(list,length);
countGrade(list,length,oldValue,newValue);
Average=list[0]+list[1]+list[2]+list[3]+list[4]+list[5]+list[6]+list[7]+list[8]+list[9]/10;
cout<<Average<<"\t";
cout<<endl;
System("panse");
}

في خطأ في main ما عرفت له ITCS Student بليز ممكن تساعدني :smile:
 
int main()
{
double list[10]={ 1.5, 2.5, 6.5,4.5,10.0, 9.5,8.2,7.0,3.5,5.5};
int length;
double Average ,oldValue ,newValue;
int A ;
computeAverage(list,length);
displayAboveAverage(list,length);
countGrade(list,length,oldValue,newValue);
Average=list[0]+list[1]+list[2]+list[3]+list[4]+list[5]+list[6]+list[7]+list[8]+list[9]/10;
cout<<Average<<"\t";
cout<<endl;
System("panse");
}

في خطأ في main ما عرفت له ITCS Student بليز ممكن تساعدني :smile:

اختي ماشتغل الmain لان
كاتبه هذي غلط
PHP:
System("panse");
المفروض
PHP:
system("pause");

ملاحظات:
جمعي main اللي الخاص بالPart A و Part B
والfunctions مع بعض
وبيصير البرنامج كامل ( والكمال لله )

Average ماتحسبينها جدي ، تحسبينها بواسطه الfunction
وبشكل عام لو ماعندنا function مثلا في الامتحان طلب Average
بعد ماتسوين جدي

تسوين for loop و متغير (sum) يجمع كل القيم
بعدين sum / length(size)

موفقين
 
مساعدة itcs104

(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.

(1) 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.

لو سمحتون الي يعرف الحل يحطه ضروري:tears:

 
(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.

(1) 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.

لو سمحتون الي يعرف الحل يحطه ضروري:tears:


حطي محاولاتش + الأعضاء يساعدونش بتوضيح فكرة السؤال و طريقة الحل
لكن الحلول الجاهزة بالكامل للأسايمنت ممنوعة في المنتدى

موفقين
 
(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 , الأول أري و الثاني السايز
فبتحطين داخل فور لوب يمشي على القيم في الأري من 0 الى حجم الأري
و تحطين متغير الى المجموع و بتحسبين المجموع عن طريق الأري
بره الأري بتحطين الأفاريج و اتعرفينه فلوت مثل المطلوب و تحطين معادلته
رتيرن أفاريج

البروتوتايب : double computeAverage (double list[] , int arrysize);

(1) 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.

هذي الفنكشن بتحسب قريد .. تستقبل باراميترز .. اري - أري سايز - فاليو قديمة و فاليو حديثة
مهمتها تغير الفاليو القديم من الأري الى الجديد

فبتسوين سيرج في الأري عن طريق فور لوب .. اذا حصل الفاليو القديم , ببدله بالفاليو الجديد

البروتوتايب : void countGrade (double list[] , double oldV , double newV, int arrysize);

-------

أي خطوة ما تعرفينها داخل البرنامج اسألي .. موفقين ^^
​
 
بالنسبة لهذا السؤال
Write a function named searchForLastOccurence that takes as parameters an array of integers, an integer key value, and the array size. The function should search for the last occurrence of the key value in the array and return its position in the array, OR return -1 if the value is not found in the array.

إذا مثلاً ما فيه الا رقم واحد هل اسوي return للـposition ولا لازم يكون فيه رقمين متشابهين أو أكثر وارجع مكان آخر رقم إذا كان موجود؟
 
بالنسبة لهذا السؤال
Write a function named searchForLastOccurence that takes as parameters an array of integers, an integer key value, and the array size. The function should search for the last occurrence of the key value in the array and return its position in the array, OR return -1 if the value is not found in the array.

إذا مثلاً ما فيه الا رقم واحد هل اسوي return للـposition ولا لازم يكون فيه رقمين متشابهين أو أكثر وارجع مكان آخر رقم إذا كان موجود؟

على حسب السؤال
لو كان عندنا Array فيها
1 , 2 , 4 , 8 , 1 , 10

وكان Key هو 1
لازم يرجع لي 5 > اللي هو location of key

الحل بسيط جداً
كل اللي عليك تقلب الloop وخلاص


بالنسبه لسؤالك اذا اصلا ماله تكرار ( يعني موجود مره وحده )
هم ماطلبوا هالتفاصيل
 
Write a function named
[FONT=Times New Roman,Times New Roman][FONT=Times New Roman,Times New Roman]displayAllOccurences [/FONT][/FONT][FONT=Times New Roman,Times New Roman][FONT=Times New Roman,Times New Roman][/FONT][/FONT]that takes as parameters an array of integers, an integer key value, and the array size. The function should search for all occurrences of the key value in the array and display their position in the array, if the value is not found in the array, the function should display a message saying that the value is not found in the array. The function prototype is:

[FONT=Times New Roman,Times New Roman][FONT=Times New Roman,Times New Roman]void displayAllOccurences(int arr[], int key, int size);
[/FONT]
[/FONT]
[FONT=Times New Roman,Times New Roman][FONT=Times New Roman,Times New Roman]

أبي أعرف هل فقط اكتب function لو احتاج انه اكتب main
هل يوجد أخطاء في function
وابي أعرف ليش حطينا داخل الشرط
كود:
[SIZE=2]found=
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
			
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2][/SIZE]

مو المفروض هذا داخل الشرط ؟؟

كود:
[SIZE=2]found(!found)
[/SIZE]


هذا حلته ويان الدكتورة بس مادري هل هذا الحل الكافي لو جان في الامتحان سؤال مثله ؟

كود:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]# include
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<iostream>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]using
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] std;[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DisplayAllOccurences([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] A[], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] key[], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] size)[/SIZE]
[SIZE=2]
{

	
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] found=[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
	
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i=0; i<size ; i++)[/SIZE]
[SIZE=2]
		
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](A[i]==key)[/SIZE]
[SIZE=2]
		{

			cout <<
[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"index= "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << i << endl;[/SIZE]
[SIZE=2]
			found=
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
			
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
		}

		found(!found)

			cout <<
[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"  "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]<<endl;[/SIZE]
[SIZE=2]
}
[/SIZE]
[/FONT]
[/FONT]
 
Write a function named
displayAllOccurences that takes as parameters an array of integers, an integer key value, and the array size. The function should search for all occurrences of the key value in the array and display their position in the array, if the value is not found in the array, the function should display a message saying that the value is not found in the array. The function prototype is:

void displayAllOccurences(int arr[], int key, int size);


أبي أعرف هل فقط اكتب function لو احتاج انه اكتب main
هل يوجد أخطاء في function
وابي أعرف ليش حطينا داخل الشرط

كود:
[SIZE=2]found=
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
            
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]

مو المفروض هذا داخل الشرط ؟؟

كود:
[SIZE=2]found(!found)
[/SIZE]


هذا حلته ويان الدكتورة بس مادري هل هذا الحل الكافي لو جان في الامتحان سؤال مثله ؟

كود:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]# include
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<iostream>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]using
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] std;[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DisplayAllOccurences([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] A[], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] key[], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] size)[/SIZE]
[SIZE=2]
{

    
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] found=[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
    
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i=0; i<size ; i++)[/SIZE]
[SIZE=2]
        
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](A[i]==key)[/SIZE]
[SIZE=2]
        {

            cout <<
[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"index= "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << i << endl;[/SIZE]
[SIZE=2]
            found=
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
            
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
        }

        found(!found)

            cout <<
[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"  "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]<<endl;[/SIZE]
[SIZE=2]
}
[/SIZE]

يعتمد على السؤال ، المطلوب بس function بس انت تبي تشوف شلون تشتغل فلازم تكتب main
يوجد خطأ بسيط
PHP:
        found(!found)
هذي اصلاً هي غلط
المفروض

PHP:
if(!found)
اهمية وجودها اذا قالوا اطبع مسج

break;
بعد غلط
احنا نبي نبحث في الأراي كامل ونطبع كل الindex يحتوي على الKey
في هالحاله بيبحث وعند اول index بيطبع وبيطلع من الloop

اتمنى افدتك
 
عندي خلل ف حل الاسايمنت :RpS_crying:
مطلوب ف الفنكشن الاولى انه نطلع ماكس بوزشن ( نطلع موقع اكبر عدد ف الاري )
وفنكشن الثانية نرتب الاري باستخدام الفنكشن الاولى
حليت الفنكشن الاولى بس الفنكشن الثانية مو قاعدين يترتبون الاعداد كامل يوصلون لموقع الماكس بوزشن ويوقف الترتيب وفيه خلل :RpS_crying: :no:

وهذا حليي ... :nosweat:

#include
<iostream>

using
namespace std;

int
maxPosition(int list[], int last);

void
selsort(int list[],int last);

int
main()

{


int list[10]={25,99,35,40,45,50,55,888,65,70};


cout<<
"the list:{25,99,35,40,45,50,55,888,65,70}"<<endl;


selsort( list, 10);

cout<<
"the list from Low to High : "<<endl;


for(int i=0;i<10;i++)

cout << list<<endl;




return 0;

}



int
maxPosition(int list[], int last)

{

int
max=0;

int
maxPosition;

for
(int i=0;i<last;i++)

if
(list>=max)

{

max=list;

maxPosition=i;

}

return
maxPosition;

}



void
selsort(int list[],int last)

{
int maxpo=maxPosition( list,10);




int smallindex,temp;



cout<<
"the maxPosition is = "<< maxPosition( list,10)<<endl;





for(int i=last;i>0;i--)

{




smallindex=maxpo;



temp=list[smallindex];

list[smallindex]=list;

list=temp;



}

}
 
^^
اختي اذا ماخاب ظني انتي فاهمه الموضوع غلط
Part a سويتينه صح
part b اذكر كان يقول use function A to do sort
هي حركه نمسح كم سطر ونضيف اسطر من
selection sort

والله اعلم
 
اي هو اعدل ف سلكت سورت واحطها بس مو عارفة امسح شنو واخلي شنو كلما سويت طلع ايرور:nosweat:
هي قالت لينا نسوي فور لوب و الاي ايكول اللينث ونسوي والاي ماينس ماينس
وقالت لنا فور لوب وحده

بس مادري شنو اخلي وشنو اشيل :no:
 
عودة
أعلى أسفل