Solved

closed account (E607ko23)
Solved
Last edited on
What's the question?
closed account (E607ko23)
a
Last edited on
What, I guess, Athar meant was that, what is your question?
Have you even tried to solve the problem?
closed account (E607ko23)
a
Last edited on
Well, how about posting your "branched" solution, then we can work on getting rid of that branch.
Do you have trouble rounding up without using if?
closed account (E607ko23)
a
Last edited on
Right, add code tags:
http://www.cplusplus.com/articles/z13hAqkS/
The code is unreadable like this.
closed account (E607ko23)
a
Last edited on
//start of function main (it is void so it doesn't return value)

With the added bonus of violating the C++ standard and failing to compile on compilers that meet the standard :)

Don't think that just because you stated void nothing is returned nothing is returned to the OS. Also don't assume that something else that might be relying on code returning an int will be happy with it not doing so.
Last edited on
closed account (E607ko23)
a
Last edited on
It's still hard to read with that kind of indentation, but alright...
there are several ways to do this, such as:

#1:
1
2
amount_of_planks=number_of_pieces/number_of_choped_pieces+
(number_of_pieces%number_of_choped_pieces!=0);  

#2:
amount_of_planks=(number_of_pieces+number_of_choped_pieces-1)/number_of_choped_pieces;
#3:
amount_of_planks=ceil(double(number_of_pieces)/number_of_choped_pieces);

I'd go with #2.
closed account (E607ko23)
Thnx i really appreciate it :D
But I don't appreciate you editing your posts.
This is no help for people with a similar problem who find this thread.
Last edited on
Grah... why do people DO that?!?!

GRAHHHH
OP:

You have planks with equal length and you need to chop from these planks pieces with same
length. The task is to develop a C++ program using linear algorithm that asks the user to input
the length of planks, length of pieces and number of pieces. The program needs to calculate and
display the number of planks that we need to produces the requested amount of pieces.

This is a home assignment, please help me!


and then

I need to calculate and display the number of planks needed to produce the requested amount of pieces in the problem above. But I should use only a linear algorithm not a branched one
Last edited on
lol
OP: Solved
Athar: What's the question?
OP: a
Nisheeth: What, I guess, Athar meant was that, what is your question?
OP: a
Athar: Well, how about posting your "branched" solution
OP: a
Athar: Right, add code tags:
OP: a
Athar: It's still hard to read with that kind of indentation, but alright...

At least it took 5 minutes to made the decision.
Topic archived. No new replies allowed.