عاشقة الدموع
Well-Known Member
- تاريخ التسجيل
- 30 أبريل 2010
- المشاركات
- 171
- المجموعة
- أنثى
- الدفعة الدراسية
- 2009
- الكلية
- كلية تقنية المعلومات
- التخصص
- CE
ثنكس اخووي يعطيك العافية
بسوي main وبطرشه اوك
بسوي main وبطرشه اوك

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;

#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;}


هذا حل دكتورة امل
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: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
هذا حاولي فيه ، عشان تستفيدين
واذا صارت صعوبات خلي الكود اللي وصلتين له وبنشوف
نسألكم الدعاء

بس كأنه في فنكشن قبل هذي سوت inseart حق 100
اله هي part a
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 بليز ممكن تساعدني![]()
System("panse");
system("pause");
(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:
بالنسبة لهذا السؤال
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 ولا لازم يكون فيه رقمين متشابهين أو أكثر وارجع مكان آخر رقم إذا كان موجود؟
[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]
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]
found(!found)
if(!found)




