When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
8 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
I'm taking inputs as N = layer number W= Weight; each block in a pyramid transfers half its weight and 15% of the pressure above it to the blocks it interacts with.
anyone who needs more info i can send detailed specifications
This question is being automatically marked as stale.
If your question has been answered, run !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.
!f
Hi guys, I'm trying to develop a program which calculates pressures of blocks in a pyramid and pr```cpp
ints all these with their coordinates.
'''
#include <stdio.h>
double
calculate_pressure_on_block(int row, int column, double block_weight) {
if (column < 0) {
row--;
column = row;
}
if (row == 0) {
printf("(0,0) 0.00000000");
return 0;
} else if ((column == 0) || (column == row)) {
if (column == 0) {
double result = calculate_pressure_on_block(row, column, block_weight);
printf("(%d,%d) %.8f", row, column, result);
calculate_pressure_on_block(row, column - 1, block_weight);
return (block_weight) / 2 + (0.15) * calculate_pressure_on_block(
row - 1, column, block_weight);
} else if (column == row) {
double result = calculate_pressure_on_block(row, column, block_weight);
printf("(%d,%d) %.8f", row, column, result);
calculate_pressure_on_block(row, column - 1, block_weight);
return (block_weight) / 2 +
(0.15) *
calculate_pressure_on_block(row - 1, column - 1, block_weight);
}
} else {
double result = calculate_pressure_on_block(row, column, block_weight);
printf("(%d,%d) %.8f", row, column, result);
calculate_pressure_on_block(row, column - 1, block_weight);
return (block_weight) / 2 +
(0.15) *
calculate_pressure_on_block(row - 1, column - 1, block_weight) +
(0.15) * calculate_pressure_on_block(row - 1, column, block_weight);
}
}
int main() {
int N;
double W;
scanf("%d %lf", &N, &W);
calculate_pressure_on_block(N - 1, N - 1, W);
return 0;
}
fyi:
Backticks (i.e. ```), not apostrophes (i.e. ''').
Also put the language after the backticks, so:
```c
int main() {
int x = 4;
}
```
which would give you:
int main() {
int x = 4;
}
A lot of identical blocks of code there. Makes it difficult to follow.