Jump to content
Forumu Destekleyenlere Katılın ×
Paticik Forumları
2000 lerden beri faal olan, çok şukela bir paylaşım platformuyuz. Hoşgeldiniz.

c freelancer'i lazım, $$


Lancelion

Öne çıkan mesajlar

proce

"procekt, wot" said:

Water Bombs for Forest Fires!
In forest fires, classical methods of fire fighting are mostly infeasible due to lack of accessibility, e.g. no roads, no fire hydrants. An alternative method is to use water bombs. These bombs contain large quantities of water (or other chemicals) and can be dropped from planes.

In this project, we have a forest fire in hand. The field of forest will be represented by a two dimensional int array. The value in a cell of the array corresponds to the intensity of the fire in that part of the forest. Below, there is a sample of forest in fire. (i,j) corresponds to the cell at the intersection of row i column j (top left is (0,0)). For example, the red cell is (0,3). The values in the cells are the intensity of the fire in that cell. Fire intensity is a non-negative integer, where zero means no fire.

27 49 69 76 97 56 87 31 3 72 56
67 90 83 45 31 83 54 67 55 23 19
34 26 38 1 10 62 12 43 90 28 20
99 82 60 6 36 34 49 41 5 31 93
64 6 12 30 87 49 40 19 26 76 40

Also we have water bombs. Every water bomb has a range of effect. In the following figure, C is a bomb with range one. This bomb only affects the cell it is dropped. On the other hand, B is a bomb with range two and it affects also the neighboring cells with distance one (the ones labeled as B_2). As seen in the figure in total bomb B affects nine cells. The effect of a water bomb on neighboring cells differs with respect to the distance from the point of impact. Therefore every bomb has an int [] which stores the effectiveness of the bomb on different ranges. For instance bomb A has a range of three, and it affects 25 cells. There is one cell labeled A_1, eight cells labeled A_2 and 16 cells labeled A_3.

A_3 A_3 A_3 A_3 A_3
B_2 B_2 B_2 A_3 A_2 A_2 A_2 A_3
C_1 B_2 B_1 B_2 A_3 A_2 A_1 A_2 A_3
B_2 B_2 B_2 A_3 A_2 A_2 A_2 A_3
A_3 A_3 A_3 A_3 A_3

Initalization

Write three structs:
struct field: this struct stores information about the field fire take place, in our case a forest. It has two int variables, which gives us the size of this field. For instance, for the field samples given above, these two int variables have the values of five and eleven. And it has a two dimensional int []. In this array the intensity of the fire is kept. The fire intensity is a nonnegative number. Zero means no fire at that area.
struct cell: this struct stores the coordinates of an area as row and column index.
struct waterbomb: this struct stores the name of the bomb (char[]), its range (int), its effect with respect to the distance (int[]) and its point of impact (struct cell). For instance in the example above A bomb has the name “A” and it has a range of three. Its point of impact is (2,8). And its effect on the fire is given in int []. The value in index zero is for area A_1, the value in index one is for area A_2 and finally the value in index two is for area A_3.

Write six functions:
void readField(struct field * write_a_variable_name): this function first reads the row and column length of the field. And then reads the fire intensity in this field. Check input samples for more details.
void printField(struct field write_a_variable_name): this function prints out the current fire intensity in this field. For the format, check input/output samples.
void readWaterBomb(struct waterbomb * write_a_variable_name): this function first reads the name(char[]), the range (int) and the effect of the bomb (int[]). It does not require point of impact. You will decide it in your program. Check input samples for more details.
void printWaterBomb(struct waterbomb write_a_variable_name): this function prints out the name of the bomb and its point of impact. It does not print out the range and effect info (however it is recommended that at first print out these info as well to be sure that readWaterBomb works as it should be). For the format, check input/output samples.
int readWaterBombs(struct waterbomb write_a_variable_name []):this function reads several waterbomb info from the user and stores these bombs info in the array given as parameter to this function. It first reads the number of the waterbombs and then reads the waterbombs using printWaterBomb. You should use printWaterBomb. Also this function returns the number of the waterbombs. Check input samples for more details.
int distance (struct cell write_a_variable_name1, struct cell write_a_variable_name2): this function calculates the distance between two cells. However the distance is not Euclidean distance. Basically it takes the maximum of the differences of coordinates. Check the following figure. Red cell’s distance to yellow one is five. And again red cell’s distance to green one is three.









2. Waterbomb Usage on Fire
Write three functions:
int calculateBombEffect (struct field write_a_variable_name1, struct waterbomb write_a_variable_name2): this function calculates the effect of this waterbomb on this field and returns this effect. However it does not change the values on the field. Do not forget that fire intensity cannot be negative. If a bomb has an effect of five and the fire intensity in that area is eleven it utilizes all of its effect decreases the intensity to six. On the other hand if the fire intensity is two, it simply becomes zero. Therefore the total effect may be less than the effect of the waterbomb. You can examine the following example. First the initial state of the fire area is given. The effect o a bomb with range 2 and an effect array of {5, 4} decreases the fire 15 units in total when dropped to (4,0) area.

Hint: While calculating the total effect of the waterbomb, scan the field as usual and for each cell check the distance (you wrote a function calculating the distance) from the point of impact. Then you can calculate the effect of the bomb in that area.

0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8

int utilizeBomb (struct field write_a_variable_name1, struct waterbomb * write_a_variable_name2): this function finds the optimal point of impact for a given bomb and sets this coordinates in the bomb. Again this function does not change the values in the field. Usage of calculateBombEffect function is mandatory. The return value is the optimal effect of the bomb on this field.
int useBomb (struct field * write_a_variable_name1, struct waterbomb write_a_variable_name2): this function drops the waterbomb on its designated target area in the field. And updates the fire intensity values after the impact. It also returns the total effect of the bomb.


3. Extra Notes

Field has maximum 100 rows.
Field has maximum 100 columns.
A bomb can have a maximum range of 100.
A bomb name can have at most 10 characters.
There will no more than 100 bombs.

Also note that you can define and use extra struct and functions.

3. Testing

Input
User enters the list of the waterbombs (first the number of the bombs, then one by one their details)
User enters the field (first its sizes then its fire intensity.)

Output
You will process the waterbombs in the given order. For each bomb you will calculate the optimal coordinates for that bomb and immediately use it. Print the name of the bomb its optimal coordinates, its effect and the field’s state after the bomb. After using all the bombs print the total effect of all the bombs


SAMPLE RUNS:
Text in bold are user’s inputs, plain text are your program’s outputs.

Sample Run 1:
3
saver
3
10 5 1
minor
1
10
reverse
2
1 3
5 5
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
saver
2 3
52
0 0 1 2 3
1 1 0 0 0
2 2 0 0 1
3 3 0 1 2
4 4 5 6 7
minor
4 4
7
0 0 1 2 3
1 1 0 0 0
2 2 0 0 1
3 3 0 1 2
4 4 5 6 0
reverse
3 1
17
0 0 1 2 3
1 1 0 0 0
0 0 0 0 1
0 2 0 1 2
1 1 2 6 0
76

Sample Run 2:
4
hero
5
10 8 6 4 2
equal
4
1 1 1 1
reverse
3
1 2 3
minor
1
2
5 7
2 3 0 7 8 6 5
7 7 5 5 4 1 3
8 4 3 5 5 5 9
3 2 4 2 4 5 5
5 7 9 4 0 8 9
hero
2 3
139
0 0 0 1 2 0 1
3 1 0 0 0 0 0
4 0 0 0 0 0 5
0 0 0 0 0 0 1
1 1 3 0 0 2 5
equal
1 3
13
0 0 0 0 1 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 4
0 0 0 0 0 0 0
0 0 2 0 0 1 4
reverse
2 4
10
0 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 1
minor
1 0
2
0 0 0 0 0 0 0
0 0 0 0 0 0 0
3 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 1
164

Please note that these sample runs are for testing your program. Giving correct results to all above sample runs does not necessarily mean that your project is 100% correct.

Link to comment
Sosyal ağlarda paylaş

Lancelion said:

proce

"procekt, wot" said:

Water Bombs for Forest Fires!
In forest fires, classical methods of fire fighting are mostly infeasible due to lack of accessibility, e.g. no roads, no fire hydrants. An alternative method is to use water bombs. These bombs contain large quantities of water (or other chemicals) and can be dropped from planes.

In this project, we have a forest fire in hand. The field of forest will be represented by a two dimensional int array. The value in a cell of the array corresponds to the intensity of the fire in that part of the forest. Below, there is a sample of forest in fire. (i,j) corresponds to the cell at the intersection of row i column j (top left is (0,0)). For example, the red cell is (0,3). The values in the cells are the intensity of the fire in that cell. Fire intensity is a non-negative integer, where zero means no fire.

27 49 69 76 97 56 87 31 3 72 56
67 90 83 45 31 83 54 67 55 23 19
34 26 38 1 10 62 12 43 90 28 20
99 82 60 6 36 34 49 41 5 31 93
64 6 12 30 87 49 40 19 26 76 40

Also we have water bombs. Every water bomb has a range of effect. In the following figure, C is a bomb with range one. This bomb only affects the cell it is dropped. On the other hand, B is a bomb with range two and it affects also the neighboring cells with distance one (the ones labeled as B_2). As seen in the figure in total bomb B affects nine cells. The effect of a water bomb on neighboring cells differs with respect to the distance from the point of impact. Therefore every bomb has an int [] which stores the effectiveness of the bomb on different ranges. For instance bomb A has a range of three, and it affects 25 cells. There is one cell labeled A_1, eight cells labeled A_2 and 16 cells labeled A_3.

A_3 A_3 A_3 A_3 A_3
B_2 B_2 B_2 A_3 A_2 A_2 A_2 A_3
C_1 B_2 B_1 B_2 A_3 A_2 A_1 A_2 A_3
B_2 B_2 B_2 A_3 A_2 A_2 A_2 A_3
A_3 A_3 A_3 A_3 A_3

Initalization

Write three structs:
struct field: this struct stores information about the field fire take place, in our case a forest. It has two int variables, which gives us the size of this field. For instance, for the field samples given above, these two int variables have the values of five and eleven. And it has a two dimensional int []. In this array the intensity of the fire is kept. The fire intensity is a nonnegative number. Zero means no fire at that area.
struct cell: this struct stores the coordinates of an area as row and column index.
struct waterbomb: this struct stores the name of the bomb (char[]), its range (int), its effect with respect to the distance (int[]) and its point of impact (struct cell). For instance in the example above A bomb has the name “A” and it has a range of three. Its point of impact is (2,8). And its effect on the fire is given in int []. The value in index zero is for area A_1, the value in index one is for area A_2 and finally the value in index two is for area A_3.

Write six functions:
void readField(struct field * write_a_variable_name): this function first reads the row and column length of the field. And then reads the fire intensity in this field. Check input samples for more details.
void printField(struct field write_a_variable_name): this function prints out the current fire intensity in this field. For the format, check input/output samples.
void readWaterBomb(struct waterbomb * write_a_variable_name): this function first reads the name(char[]), the range (int) and the effect of the bomb (int[]). It does not require point of impact. You will decide it in your program. Check input samples for more details.
void printWaterBomb(struct waterbomb write_a_variable_name): this function prints out the name of the bomb and its point of impact. It does not print out the range and effect info (however it is recommended that at first print out these info as well to be sure that readWaterBomb works as it should be). For the format, check input/output samples.
int readWaterBombs(struct waterbomb write_a_variable_name []):this function reads several waterbomb info from the user and stores these bombs info in the array given as parameter to this function. It first reads the number of the waterbombs and then reads the waterbombs using printWaterBomb. You should use printWaterBomb. Also this function returns the number of the waterbombs. Check input samples for more details.
int distance (struct cell write_a_variable_name1, struct cell write_a_variable_name2): this function calculates the distance between two cells. However the distance is not Euclidean distance. Basically it takes the maximum of the differences of coordinates. Check the following figure. Red cell’s distance to yellow one is five. And again red cell’s distance to green one is three.









2. Waterbomb Usage on Fire
Write three functions:
int calculateBombEffect (struct field write_a_variable_name1, struct waterbomb write_a_variable_name2): this function calculates the effect of this waterbomb on this field and returns this effect. However it does not change the values on the field. Do not forget that fire intensity cannot be negative. If a bomb has an effect of five and the fire intensity in that area is eleven it utilizes all of its effect decreases the intensity to six. On the other hand if the fire intensity is two, it simply becomes zero. Therefore the total effect may be less than the effect of the waterbomb. You can examine the following example. First the initial state of the fire area is given. The effect o a bomb with range 2 and an effect array of {5, 4} decreases the fire 15 units in total when dropped to (4,0) area.

Hint: While calculating the total effect of the waterbomb, scan the field as usual and for each cell check the distance (you wrote a function calculating the distance) from the point of impact. Then you can calculate the effect of the bomb in that area.

0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8

int utilizeBomb (struct field write_a_variable_name1, struct waterbomb * write_a_variable_name2): this function finds the optimal point of impact for a given bomb and sets this coordinates in the bomb. Again this function does not change the values in the field. Usage of calculateBombEffect function is mandatory. The return value is the optimal effect of the bomb on this field.
int useBomb (struct field * write_a_variable_name1, struct waterbomb write_a_variable_name2): this function drops the waterbomb on its designated target area in the field. And updates the fire intensity values after the impact. It also returns the total effect of the bomb.


3. Extra Notes

Field has maximum 100 rows.
Field has maximum 100 columns.
A bomb can have a maximum range of 100.
A bomb name can have at most 10 characters.
There will no more than 100 bombs.

Also note that you can define and use extra struct and functions.

3. Testing

Input
User enters the list of the waterbombs (first the number of the bombs, then one by one their details)
User enters the field (first its sizes then its fire intensity.)

Output
You will process the waterbombs in the given order. For each bomb you will calculate the optimal coordinates for that bomb and immediately use it. Print the name of the bomb its optimal coordinates, its effect and the field’s state after the bomb. After using all the bombs print the total effect of all the bombs


SAMPLE RUNS:
Text in bold are user’s inputs, plain text are your program’s outputs.

Sample Run 1:
3
saver
3
10 5 1
minor
1
10
reverse
2
1 3
5 5
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
saver
2 3
52
0 0 1 2 3
1 1 0 0 0
2 2 0 0 1
3 3 0 1 2
4 4 5 6 7
minor
4 4
7
0 0 1 2 3
1 1 0 0 0
2 2 0 0 1
3 3 0 1 2
4 4 5 6 0
reverse
3 1
17
0 0 1 2 3
1 1 0 0 0
0 0 0 0 1
0 2 0 1 2
1 1 2 6 0
76

Sample Run 2:
4
hero
5
10 8 6 4 2
equal
4
1 1 1 1
reverse
3
1 2 3
minor
1
2
5 7
2 3 0 7 8 6 5
7 7 5 5 4 1 3
8 4 3 5 5 5 9
3 2 4 2 4 5 5
5 7 9 4 0 8 9
hero
2 3
139
0 0 0 1 2 0 1
3 1 0 0 0 0 0
4 0 0 0 0 0 5
0 0 0 0 0 0 1
1 1 3 0 0 2 5
equal
1 3
13
0 0 0 0 1 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 4
0 0 0 0 0 0 0
0 0 2 0 0 1 4
reverse
2 4
10
0 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 1
minor
1 0
2
0 0 0 0 0 0 0
0 0 0 0 0 0 0
3 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 1
164

Please note that these sample runs are for testing your program. Giving correct results to all above sample runs does not necessarily mean that your project is 100% correct.


25€'ya bunu en çok okurum..
Link to comment
Sosyal ağlarda paylaş

Suark said:

abi elektronik 1. sınıfmış
proje dediği ödevdir, factoriel falan hesaplatıolardır falan yani.

yazık lan parasız yapın :D


evet 20-25 eur. belki 2-3 durume de tavlanabilir

Lancelion said:

proce

"procekt, wot" said:

Water Bombs for Forest Fires!
In forest fires, classical methods of fire fighting are mostly infeasible due to lack of accessibility, e.g. no roads, no fire hydrants. An alternative method is to use water bombs. These bombs contain large quantities of water (or other chemicals) and can be dropped from planes.

In this project, we have a forest fire in hand. The field of forest will be represented by a two dimensional int array. The value in a cell of the array corresponds to the intensity of the fire in that part of the forest. Below, there is a sample of forest in fire. (i,j) corresponds to the cell at the intersection of row i column j (top left is (0,0)). For example, the red cell is (0,3). The values in the cells are the intensity of the fire in that cell. Fire intensity is a non-negative integer, where zero means no fire.

27 49 69 76 97 56 87 31 3 72 56
67 90 83 45 31 83 54 67 55 23 19
34 26 38 1 10 62 12 43 90 28 20
99 82 60 6 36 34 49 41 5 31 93
64 6 12 30 87 49 40 19 26 76 40

Also we have water bombs. Every water bomb has a range of effect. In the following figure, C is a bomb with range one. This bomb only affects the cell it is dropped. On the other hand, B is a bomb with range two and it affects also the neighboring cells with distance one (the ones labeled as B_2). As seen in the figure in total bomb B affects nine cells. The effect of a water bomb on neighboring cells differs with respect to the distance from the point of impact. Therefore every bomb has an int [] which stores the effectiveness of the bomb on different ranges. For instance bomb A has a range of three, and it affects 25 cells. There is one cell labeled A_1, eight cells labeled A_2 and 16 cells labeled A_3.

A_3 A_3 A_3 A_3 A_3
B_2 B_2 B_2 A_3 A_2 A_2 A_2 A_3
C_1 B_2 B_1 B_2 A_3 A_2 A_1 A_2 A_3
B_2 B_2 B_2 A_3 A_2 A_2 A_2 A_3
A_3 A_3 A_3 A_3 A_3

Initalization

Write three structs:
struct field: this struct stores information about the field fire take place, in our case a forest. It has two int variables, which gives us the size of this field. For instance, for the field samples given above, these two int variables have the values of five and eleven. And it has a two dimensional int []. In this array the intensity of the fire is kept. The fire intensity is a nonnegative number. Zero means no fire at that area.
struct cell: this struct stores the coordinates of an area as row and column index.
struct waterbomb: this struct stores the name of the bomb (char[]), its range (int), its effect with respect to the distance (int[]) and its point of impact (struct cell). For instance in the example above A bomb has the name “A” and it has a range of three. Its point of impact is (2,8). And its effect on the fire is given in int []. The value in index zero is for area A_1, the value in index one is for area A_2 and finally the value in index two is for area A_3.

Write six functions:
void readField(struct field * write_a_variable_name): this function first reads the row and column length of the field. And then reads the fire intensity in this field. Check input samples for more details.
void printField(struct field write_a_variable_name): this function prints out the current fire intensity in this field. For the format, check input/output samples.
void readWaterBomb(struct waterbomb * write_a_variable_name): this function first reads the name(char[]), the range (int) and the effect of the bomb (int[]). It does not require point of impact. You will decide it in your program. Check input samples for more details.
void printWaterBomb(struct waterbomb write_a_variable_name): this function prints out the name of the bomb and its point of impact. It does not print out the range and effect info (however it is recommended that at first print out these info as well to be sure that readWaterBomb works as it should be). For the format, check input/output samples.
int readWaterBombs(struct waterbomb write_a_variable_name []):this function reads several waterbomb info from the user and stores these bombs info in the array given as parameter to this function. It first reads the number of the waterbombs and then reads the waterbombs using printWaterBomb. You should use printWaterBomb. Also this function returns the number of the waterbombs. Check input samples for more details.
int distance (struct cell write_a_variable_name1, struct cell write_a_variable_name2): this function calculates the distance between two cells. However the distance is not Euclidean distance. Basically it takes the maximum of the differences of coordinates. Check the following figure. Red cell’s distance to yellow one is five. And again red cell’s distance to green one is three.









2. Waterbomb Usage on Fire
Write three functions:
int calculateBombEffect (struct field write_a_variable_name1, struct waterbomb write_a_variable_name2): this function calculates the effect of this waterbomb on this field and returns this effect. However it does not change the values on the field. Do not forget that fire intensity cannot be negative. If a bomb has an effect of five and the fire intensity in that area is eleven it utilizes all of its effect decreases the intensity to six. On the other hand if the fire intensity is two, it simply becomes zero. Therefore the total effect may be less than the effect of the waterbomb. You can examine the following example. First the initial state of the fire area is given. The effect o a bomb with range 2 and an effect array of {5, 4} decreases the fire 15 units in total when dropped to (4,0) area.

Hint: While calculating the total effect of the waterbomb, scan the field as usual and for each cell check the distance (you wrote a function calculating the distance) from the point of impact. Then you can calculate the effect of the bomb in that area.

0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8

int utilizeBomb (struct field write_a_variable_name1, struct waterbomb * write_a_variable_name2): this function finds the optimal point of impact for a given bomb and sets this coordinates in the bomb. Again this function does not change the values in the field. Usage of calculateBombEffect function is mandatory. The return value is the optimal effect of the bomb on this field.
int useBomb (struct field * write_a_variable_name1, struct waterbomb write_a_variable_name2): this function drops the waterbomb on its designated target area in the field. And updates the fire intensity values after the impact. It also returns the total effect of the bomb.


3. Extra Notes

Field has maximum 100 rows.
Field has maximum 100 columns.
A bomb can have a maximum range of 100.
A bomb name can have at most 10 characters.
There will no more than 100 bombs.

Also note that you can define and use extra struct and functions.

3. Testing

Input
User enters the list of the waterbombs (first the number of the bombs, then one by one their details)
User enters the field (first its sizes then its fire intensity.)

Output
You will process the waterbombs in the given order. For each bomb you will calculate the optimal coordinates for that bomb and immediately use it. Print the name of the bomb its optimal coordinates, its effect and the field’s state after the bomb. After using all the bombs print the total effect of all the bombs


SAMPLE RUNS:
Text in bold are user’s inputs, plain text are your program’s outputs.

Sample Run 1:
3
saver
3
10 5 1
minor
1
10
reverse
2
1 3
5 5
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
saver
2 3
52
0 0 1 2 3
1 1 0 0 0
2 2 0 0 1
3 3 0 1 2
4 4 5 6 7
minor
4 4
7
0 0 1 2 3
1 1 0 0 0
2 2 0 0 1
3 3 0 1 2
4 4 5 6 0
reverse
3 1
17
0 0 1 2 3
1 1 0 0 0
0 0 0 0 1
0 2 0 1 2
1 1 2 6 0
76

Sample Run 2:
4
hero
5
10 8 6 4 2
equal
4
1 1 1 1
reverse
3
1 2 3
minor
1
2
5 7
2 3 0 7 8 6 5
7 7 5 5 4 1 3
8 4 3 5 5 5 9
3 2 4 2 4 5 5
5 7 9 4 0 8 9
hero
2 3
139
0 0 0 1 2 0 1
3 1 0 0 0 0 0
4 0 0 0 0 0 5
0 0 0 0 0 0 1
1 1 3 0 0 2 5
equal
1 3
13
0 0 0 0 1 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 4
0 0 0 0 0 0 0
0 0 2 0 0 1 4
reverse
2 4
10
0 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 1
minor
1 0
2
0 0 0 0 0 0 0
0 0 0 0 0 0 0
3 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 1
164

Please note that these sample runs are for testing your program. Giving correct results to all above sample runs does not necessarily mean that your project is 100% correct.



200-250 eur, durum dunyasina tavlanabilir.

devren alinik sube
Link to comment
Sosyal ağlarda paylaş

Joker said:

Lancelion said:

proce

"procekt, wot" said:

Water Bombs for Forest Fires!
In forest fires, classical methods of fire fighting are mostly infeasible due to lack of accessibility, e.g. no roads, no fire hydrants. An alternative method is to use water bombs. These bombs contain large quantities of water (or other chemicals) and can be dropped from planes.

In this project, we have a forest fire in hand. The field of forest will be represented by a two dimensional int array. The value in a cell of the array corresponds to the intensity of the fire in that part of the forest. Below, there is a sample of forest in fire. (i,j) corresponds to the cell at the intersection of row i column j (top left is (0,0)). For example, the red cell is (0,3). The values in the cells are the intensity of the fire in that cell. Fire intensity is a non-negative integer, where zero means no fire.

27 49 69 76 97 56 87 31 3 72 56
67 90 83 45 31 83 54 67 55 23 19
34 26 38 1 10 62 12 43 90 28 20
99 82 60 6 36 34 49 41 5 31 93
64 6 12 30 87 49 40 19 26 76 40

Also we have water bombs. Every water bomb has a range of effect. In the following figure, C is a bomb with range one. This bomb only affects the cell it is dropped. On the other hand, B is a bomb with range two and it affects also the neighboring cells with distance one (the ones labeled as B_2). As seen in the figure in total bomb B affects nine cells. The effect of a water bomb on neighboring cells differs with respect to the distance from the point of impact. Therefore every bomb has an int [] which stores the effectiveness of the bomb on different ranges. For instance bomb A has a range of three, and it affects 25 cells. There is one cell labeled A_1, eight cells labeled A_2 and 16 cells labeled A_3.

A_3 A_3 A_3 A_3 A_3
B_2 B_2 B_2 A_3 A_2 A_2 A_2 A_3
C_1 B_2 B_1 B_2 A_3 A_2 A_1 A_2 A_3
B_2 B_2 B_2 A_3 A_2 A_2 A_2 A_3
A_3 A_3 A_3 A_3 A_3

Initalization

Write three structs:
struct field: this struct stores information about the field fire take place, in our case a forest. It has two int variables, which gives us the size of this field. For instance, for the field samples given above, these two int variables have the values of five and eleven. And it has a two dimensional int []. In this array the intensity of the fire is kept. The fire intensity is a nonnegative number. Zero means no fire at that area.
struct cell: this struct stores the coordinates of an area as row and column index.
struct waterbomb: this struct stores the name of the bomb (char[]), its range (int), its effect with respect to the distance (int[]) and its point of impact (struct cell). For instance in the example above A bomb has the name “A” and it has a range of three. Its point of impact is (2,8). And its effect on the fire is given in int []. The value in index zero is for area A_1, the value in index one is for area A_2 and finally the value in index two is for area A_3.

Write six functions:
void readField(struct field * write_a_variable_name): this function first reads the row and column length of the field. And then reads the fire intensity in this field. Check input samples for more details.
void printField(struct field write_a_variable_name): this function prints out the current fire intensity in this field. For the format, check input/output samples.
void readWaterBomb(struct waterbomb * write_a_variable_name): this function first reads the name(char[]), the range (int) and the effect of the bomb (int[]). It does not require point of impact. You will decide it in your program. Check input samples for more details.
void printWaterBomb(struct waterbomb write_a_variable_name): this function prints out the name of the bomb and its point of impact. It does not print out the range and effect info (however it is recommended that at first print out these info as well to be sure that readWaterBomb works as it should be). For the format, check input/output samples.
int readWaterBombs(struct waterbomb write_a_variable_name []):this function reads several waterbomb info from the user and stores these bombs info in the array given as parameter to this function. It first reads the number of the waterbombs and then reads the waterbombs using printWaterBomb. You should use printWaterBomb. Also this function returns the number of the waterbombs. Check input samples for more details.
int distance (struct cell write_a_variable_name1, struct cell write_a_variable_name2): this function calculates the distance between two cells. However the distance is not Euclidean distance. Basically it takes the maximum of the differences of coordinates. Check the following figure. Red cell’s distance to yellow one is five. And again red cell’s distance to green one is three.









2. Waterbomb Usage on Fire
Write three functions:
int calculateBombEffect (struct field write_a_variable_name1, struct waterbomb write_a_variable_name2): this function calculates the effect of this waterbomb on this field and returns this effect. However it does not change the values on the field. Do not forget that fire intensity cannot be negative. If a bomb has an effect of five and the fire intensity in that area is eleven it utilizes all of its effect decreases the intensity to six. On the other hand if the fire intensity is two, it simply becomes zero. Therefore the total effect may be less than the effect of the waterbomb. You can examine the following example. First the initial state of the fire area is given. The effect o a bomb with range 2 and an effect array of {5, 4} decreases the fire 15 units in total when dropped to (4,0) area.

Hint: While calculating the total effect of the waterbomb, scan the field as usual and for each cell check the distance (you wrote a function calculating the distance) from the point of impact. Then you can calculate the effect of the bomb in that area.

0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8

int utilizeBomb (struct field write_a_variable_name1, struct waterbomb * write_a_variable_name2): this function finds the optimal point of impact for a given bomb and sets this coordinates in the bomb. Again this function does not change the values in the field. Usage of calculateBombEffect function is mandatory. The return value is the optimal effect of the bomb on this field.
int useBomb (struct field * write_a_variable_name1, struct waterbomb write_a_variable_name2): this function drops the waterbomb on its designated target area in the field. And updates the fire intensity values after the impact. It also returns the total effect of the bomb.


3. Extra Notes

Field has maximum 100 rows.
Field has maximum 100 columns.
A bomb can have a maximum range of 100.
A bomb name can have at most 10 characters.
There will no more than 100 bombs.

Also note that you can define and use extra struct and functions.

3. Testing

Input
User enters the list of the waterbombs (first the number of the bombs, then one by one their details)
User enters the field (first its sizes then its fire intensity.)

Output
You will process the waterbombs in the given order. For each bomb you will calculate the optimal coordinates for that bomb and immediately use it. Print the name of the bomb its optimal coordinates, its effect and the field’s state after the bomb. After using all the bombs print the total effect of all the bombs


SAMPLE RUNS:
Text in bold are user’s inputs, plain text are your program’s outputs.

Sample Run 1:
3
saver
3
10 5 1
minor
1
10
reverse
2
1 3
5 5
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
saver
2 3
52
0 0 1 2 3
1 1 0 0 0
2 2 0 0 1
3 3 0 1 2
4 4 5 6 7
minor
4 4
7
0 0 1 2 3
1 1 0 0 0
2 2 0 0 1
3 3 0 1 2
4 4 5 6 0
reverse
3 1
17
0 0 1 2 3
1 1 0 0 0
0 0 0 0 1
0 2 0 1 2
1 1 2 6 0
76

Sample Run 2:
4
hero
5
10 8 6 4 2
equal
4
1 1 1 1
reverse
3
1 2 3
minor
1
2
5 7
2 3 0 7 8 6 5
7 7 5 5 4 1 3
8 4 3 5 5 5 9
3 2 4 2 4 5 5
5 7 9 4 0 8 9
hero
2 3
139
0 0 0 1 2 0 1
3 1 0 0 0 0 0
4 0 0 0 0 0 5
0 0 0 0 0 0 1
1 1 3 0 0 2 5
equal
1 3
13
0 0 0 0 1 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 4
0 0 0 0 0 0 0
0 0 2 0 0 1 4
reverse
2 4
10
0 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 1
minor
1 0
2
0 0 0 0 0 0 0
0 0 0 0 0 0 0
3 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 1
164

Please note that these sample runs are for testing your program. Giving correct results to all above sample runs does not necessarily mean that your project is 100% correct.


25€'ya bunu en çok okurum..


iyi ki bazılarının paraya çok ihtiyacı oluyor ~~
Link to comment
Sosyal ağlarda paylaş

×
×
  • Yeni Oluştur...