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

سؤال في البرمجه

بدأه DAX 99 في 4 أبريل 2011 · 5 رد · 624 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

ان شاء الله تكونون بخير ،

عندي سؤال وياليت اللي يعرف يجاوبني واكون من الشاكرين له

write a program which finds the largest and second largest numbers of ten entered . the numbers can only be enterd once .

examble :

1 15 43 3 21 6 7 66 11 20

largest : 66

second largest : 43

آنتظر آجآباتكم عشان بكرا عندي آختبار عليه ، وانا بحاول باللي اقدر عليه :mellow:

#2

This assignment is about a robot that can move around his environment and he uses informed search.

This homework assignment is to program an A* heuristic search to allow an agent to compute the shortest path from a start point to a goal point that goes around obstacles. The scenario of this problem is that the robot, of a circular shape, is located at point A and he needs to get to point C. He can move to any point that has a non negative coordinates. However, there are also a set of obstacles, so he cannot move directly from A to C, but must instead avoid the obstacles. To make the problem a little computationally simpler, we will limit the obstacles to be rectangles, circles and squares.

The robot (circle) wants to plan a path from A to C that does not cut across or touch any of the obstacles. A move from a point X can be one unit in each of the four directions: left, right, up and down. A move from one point to another must not go through or touch any obstacle.

For the A* algorithm, you will need an Open list and a Closed list. The Open list contains states that have been generated and not yet expanded. The Closed list contains states that have already been expanded. Each state contains at least the following:

• the coordinates of a point

• the g-value cost of the path from the initial state to this state

• the h-value that estimates the cost from this state to the goal

• the f-value that is the sum of these two

• Apointer to the parent state

The possible operators at each state are just the moves to any of the other states. Many of them will be illegal, because moving the robot (circle) from the current state to the other state intersects or touches an obstacle. Therefore, you will need to code a utility function that determines if a given circle intersects a given rectangle, square and circle. The heuristic function h should use the straight line distance from the current state to the goal state, which can never overestimate the true distance.

Testing

Your program should read the input data from a file. The format of the file is as follows.

1. The first line contains 3 numbers separated by spaces. These are the X and Y (integers) coordinates of the center of the robot (circle) initial state, and the raduis (float) of the circle.

2. The second line contains 2 integers separated by spaces. These are the X and Y coordinates of the center of the robot (circle) goal state.

3. The third line contains 1 (integer) number. This is the number of obstacles.

4. Each of the remaining lines gives the type and position of an obstacle. A circle obstacle is represented by a line containing character C/c two integer numbers representing the coordinates of the center, one real number representing the radius. A rectangle obstacle is represented by a line containing the character R/r, two integer numbers representing the coordinates of the upper-left corner, a real number representing the length and a real number representing height. A square obstacle is represented by a line containing the character S/s, two integer numbers representing the coordinates of the upper-left corner, and a real number representing the length.

Results

Your solution will be the minimal path from the start state to the goal state that does not intersect or touches the obstacles. You should output both the path and its cost. The path can be found by following the parent pointers backward from the goal state. For example, the program should execute as follows:

Enter input file name and path: c:\points.txt

The path from the initial to goal state is:

1,15

1,14

1,13

2,13

2,14

…

50,50

Total distance is …

رجاءا حدا يساعدني بهالموضوع قبل 18/4/2011

ع الايميل zozakash@hotmail.com

#3
اقتباس
This assignment is about a robot that can move around his environment and he uses informed search.

This homework assignment is to program an A* heuristic search to allow an agent to compute the shortest path from a start point to a goal point that goes around obstacles. The scenario of this problem is that the robot, of a circular shape, is located at point A and he needs to get to point C. He can move to any point that has a non negative coordinates. However, there are also a set of obstacles, so he cannot move directly from A to C, but must instead avoid the obstacles. To make the problem a little computationally simpler, we will limit the obstacles to be rectangles, circles and squares.

The robot (circle) wants to plan a path from A to C that does not cut across or touch any of the obstacles. A move from a point X can be one unit in each of the four directions: left, right, up and down. A move from one point to another must not go through or touch any obstacle.

For the A* algorithm, you will need an Open list and a Closed list. The Open list contains states that have been generated and not yet expanded. The Closed list contains states that have already been expanded. Each state contains at least the following:

• the coordinates of a point

• the g-value cost of the path from the initial state to this state

• the h-value that estimates the cost from this state to the goal

• the f-value that is the sum of these two

• Apointer to the parent state

The possible operators at each state are just the moves to any of the other states. Many of them will be illegal, because moving the robot (circle) from the current state to the other state intersects or touches an obstacle. Therefore, you will need to code a utility function that determines if a given circle intersects a given rectangle, square and circle. The heuristic function h should use the straight line distance from the current state to the goal state, which can never overestimate the true distance.

Testing

Your program should read the input data from a file. The format of the file is as follows.

1. The first line contains 3 numbers separated by spaces. These are the X and Y (integers) coordinates of the center of the robot (circle) initial state, and the raduis (float) of the circle.

2. The second line contains 2 integers separated by spaces. These are the X and Y coordinates of the center of the robot (circle) goal state.

3. The third line contains 1 (integer) number. This is the number of obstacles.

4. Each of the remaining lines gives the type and position of an obstacle. A circle obstacle is represented by a line containing character C/c two integer numbers representing the coordinates of the center, one real number representing the radius. A rectangle obstacle is represented by a line containing the character R/r, two integer numbers representing the coordinates of the upper-left corner, a real number representing the length and a real number representing height. A square obstacle is represented by a line containing the character S/s, two integer numbers representing the coordinates of the upper-left corner, and a real number representing the length.

Results

Your solution will be the minimal path from the start state to the goal state that does not intersect or touches the obstacles. You should output both the path and its cost. The path can be found by following the parent pointers backward from the goal state. For example, the program should execute as follows:

Enter input file name and path: c:\points.txt

The path from the initial to goal state is:

1,15

1,14

1,13

2,13

2,14

…

50,50

Total distance is …

رجاءا حدا يساعدني بهالموضوع قبل 18/4/2011

ع الايميل zozakash@hotmail.com

على الاقل احترمني كشخص منزل الموضوع وانتظر اجابه

#4
DAX 99 كتب:

السلام عليكم

ان شاء الله تكونون بخير ،

عندي سؤال وياليت اللي يعرف يجاوبني واكون من الشاكرين له

write a program which finds the largest and second largest numbers of ten entered . the numbers can only be enterd once .

examble :

1 15 43 3 21 6 7 66 11 20

largest : 66

second largest : 43

آنتظر آجآباتكم عشان بكرا عندي آختبار عليه ، وانا بحاول باللي اقدر عليه :mellow:

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

تستطيع أخي أن ترتبهم (تصاعدي أو تنازلي) و بعدها تستخرج العدد الأكبر و ثاني أكبر عدد بسهوله

و إذا كنت لا تريد أن ترتبهم فيمكنك إستخراج أكبر عدد مرتين

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

و سيكون عندك في النهاية أكبر عدد و ثاني أكبر عدد

أفضل إستخدام الطريقة الأولى و لكن عرضت الطريقة الثانية في حال إنك لاتريد ترتيبهم

بالتوفيق ..

تم تعديل هذه المشاركة بواسطة TheUnknown في 7 أبريل 2011 في 08:13

كلما أدبني الدهر ... أراني نقص عقلي

كلما أزددت علما ... زادني علما بجهلي

#5

لم افهم ؟

هل الطريقه هذه نافعه اذا سمحنا للمستخدم نفسه ادخال الارقام ؟؟

#6
ح ـور كتب:

لم افهم ؟

هل الطريقه هذه نافعه اذا سمحنا للمستخدم نفسه ادخال الارقام ؟؟

نعم,

حيث إن الأرقام سيتم تخزينها في مصفوفة بعدها يتم ترتيب الأرقام و إستخراج أكبر رقم بسهولة

بالتوفيق ..

كلما أدبني الدهر ... أراني نقص عقلي

كلما أزددت علما ... زادني علما بجهلي

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…