الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

إلى كل المبرمجين العارفين بلغة C

مغلق
بدأه hussain79_02 في 21 فبراير 2003 · 6 رد · 934 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

إلى كل المبرمجين العارفين بلغة C

أخوتي و أخواتي :

أريد حلا لهذه المسائل فأنا طالب جامعي و أدرس حاليا و كبداية لغة ال C و أنا في بداية دراستي للبرمجة و أريد منكم المساعدة و أرجو أن يكون الحل بلغة C و ليس C++:

]Problem:

1- write a function name ReadArray that takes as parameters an

intger array and its size The function should ask the user to enter

intger numbers and store them in the array. The prototype of the

function is void ReadArray( int [] , int).

2- write a function named PrintArray that takes as a parameter an

array and its size. The function should print the contents of the

array. The prototype of the function is void PrintFunct( int [], int ).

3- write a function named CountOccurences that takes as parameters two integer arrays A and B and their sizes. The function should count the number of elements in the array A that occur in array B. The prototype of the function is int CountOccurences( int A[] , int B[], int sizeA, int sizeB).

4- write a function named SortArray that takes as a parameter an array and its size .The function should sort the array in ascending order. Use an intelligent bubble sort algorithm. The prototype of the function is void SortArray(int[],int).

5- write a main function that calls the functions 1,2,3,4

#2

أخي حسين لنرى بداياتك في حل السؤال و تصورك لنتابع معك :)

راجع شروط الكتابة في القسم (f)

#3

بسمه تعالى

الأخ العزيز طلال

السلام عليكم و رحمة الله و بركاته .. تحية مباركة

أعتذر لطول المدة التي لم أرسل لك الرد فيه و هذا هو الجواب و هو بمساعدة أحد الأخوة

//Prototypes//

-------------------

void ReadArray(int[], int);

void PrintFunct(int[], int);

int CountOccurences(int[] ,int[] , int, int);

void SortArray(int[],int);

//ReadArray//

-----------------

void ReadArray(int iArray[], int nSize)

{

int iCounter = nSize;

while(iCounter > 0)

{

printf("nEnter a value: ");

scanf("%d", &iArray[iCounter]);

iCounter--;

}

}

//PrintFunct//

----------------

void PrintFunct(int iArray[], int nSize)

{

int iCounter = nSize;

while(iCounter >= 0)

{

printf("%dn", iArray[iCounter]);

iCounter--;

}

}

//CountOccurences//

--------------------------

int CountOccurences(int iArray_A[] ,int iArray_B[] ,int nSize_A,int nSize_B)

{

int iCounter = 0;

int iOccurenceCounter = 0;

while (nSize_B >= 0)

{

iCounter = nSize_A;

while (iCounter >= 0)

{

if (iArray_A[iCounter] == iArray_B[nSize_B])

iOccurenceCounter++;

iCounter--;

}

nSize_B--;

}

return iOccurenceCounter;

}

//SortArray//

-----------------

void SortArray(int iArray[],int nSize)

{

int iCounter = nSize ;

int iTempNumber;

while (nSize >= 0)

{

while (iCounter >= 0)

{

if(iArray[iCounter] <= iArray[nSize])

{

iTempNumber = iArray[iCounter];

iArray[iCounter] = iArray[nSize];

iArray[nSize] = iTempNumber;

}

iCounter--;

}

nSize--;

iCounter = nSize - 1;

}

}

//Main//

-------------------

main()

{

int iArray_A[5+1];

int iArray_B[8+1] = {50, 3, 5, 8, 6, 2, 7, 9};

int Occurences;

ReadArray(iArray_A, 5);

PrintFunct(iArray_A, 5);

SortArray(iArray_A, 5);

PrintFunct(iArray_A, 5);

Occurences = CountOccurences(iArray_A, iArray_B, 5, 8);

printf("Occurences = %dn",Occurences);

return 0;

}

#4

أخ حسين

هل من الممكن وضع رابط لموقع المادة التي تدرسها و هل بالإمكان أيضا الحصول على اسم الكتاب المقرر و الشرائح و المذكرات للمادة و أيضا الواجبات

و شكرا

#5

إلى الأخ العزيز ::'( hussain79_02 :'(

على الأقل أو من المفروض أن تطرح سؤالك باللغة العربية لا بالأنقليزي...

و شكرا

#6

بسم الله الرحمن الرحيم

السلام عليكم و رحمة الله و بركاته ... تحياتي

اخي العزيز bozoclown2000:

ان المادة التي أدرسها حاليا هي السي و ليست سي++ و اسم المقرر هو how to programm C و اسم مؤلف الكتاب هوdeitel & deitil و الاصدار هو الثالث

و الموقع الذي يمكن الحصول منه على الكتاب هو www.deitel.com و

www.prenhall.com/deitel

و مثال على البرامج و الواجبات هذا السؤال

The game of life is a computer simulation of the life and death events of population of bacteria.Write a program to simulate the game of life. The program should determine the life, death and survival of bacteria from one generation to yhe next using the follwing rules:

• Every empty cell with three living neighbors will come to life in the next generation

• Any cell with one or zero neighbors will die of loneliness, while any cell with four or more neighbors will die from overcroweding.

• Any cell with two or three neighbors will live into the generation.

Program Requirments:

1. The cells of the game will be represented by a matrix ( 50 X 50 ) of type character>

2. A DisplyBacteria function that takes a matrix and its size then displays the matrix on the screen.

3. A InitializeBacteria function that takes a matrix and its size as parameters and randomly assigns 'X' (occupied cell ) or ' ' (empty cell) to all the cell in the matrix.

4. A CountNeighbors function that takes a matrix, its size, the position of a specified cell which is the row and column number.The function should calculate and return the number of neighbors(occupied cell) for a given cell.

5. A UpdateBacteria function that calls the CountNeighbors function and controls which cells live and die.

6. Display 100 generations. Clear the screen after each generation.

#7

اخي العزيز

السلام عليكم و رحمة الله و بركاته

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

و دمتم في رعاية الله

هذا الموضوع مغلق.

مواضيع مشابهة