can someone help me with whole code? |
No. We generally do not do that. However if you post what you have, and outline problems you encountered, we might help you (and give advice how to improve your existing code)
You have several steps which you need to do:
user will input number of sides to choose from |
Get amount from user
so it means and array will have to allocate memory based on the first number |
Create array/vector/container of that size
then second number input is the perimeter of the triangle |
Get input from user and store it.
you will fill the array with the sides |
Get user input in a loop filling your array.
Did you have problems with any of these?
No I will give some hints on your last problem:
if its possible to create the triangle from any 3 sides from the whole array |
Rough algorithm is simple: pick first three sides, check if they have proper perimeter, check if they form a valid triangle. Then pick next three, and so on.
Naive loop:
1 2 3 4
|
for(i = [0, size))
for(j = [0, size))
for(k = [0, size))
check_if_fit(array[i], array[j], array[k])
|
This will loop through all combinations and is guaranteed to find
each possible triangle. (actually it will find it no less than 6 times).
When you will have working code, you can start optimising (removing repetitions and general speedup), but this should be done
after you have working code.
P.S. Posting same question again and again will not give you help if you never react to advices given and questions asked in previous threads.