Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: You have just put in a new garden for your summer plants and would like

ID: 3538078 • Letter: P

Question

Problem: You have just put in a new garden for your summer plants and would like to add a decorative edging around it. The problem is that you have three different shapes left over from a previous similar project and you don't believe using more than any two different shapes would look good around your garden. Determine the longest string of exactly two alternative shapes you could assemble given the quantity of each shape you have available.



SAMPLE EXECUTION:


Enter number of bricks: 2


Enter number of spheres: 5


Enter number of prisms: 1


Longest possible string of alternating shapes using only two different shapes: 5


SAMPle EXECUTION 2:




What is the logic ? **WE CANNOT USE IF/ELSE STATEMENTS, OR SELECTION" No user defined functions.


Use the basic math operators +, -, *, /, %. Hint: ratios!

Explanation / Answer

#include<stdio.h>

#define MIN(num1, num2) ((num1 < num2) ? num1 : num2)

#define MAX(num1,num2) ((num1 > num2) ? num1 : num2)


void main(){

int b,s,p;

int min,mid,max;

scanf("%d %d %d",&b,&s,&p);

(b = MIN(b,s) && b = MIN(b,p))? (min = b,max = MAX(s,p),mid=MIN(s,p)):(min=MIN(s,p),max=MAX(b,MAX(s,p)),mid=MIN(b,MAX(s,p)));

(mid == max )? printf("answer is %d",(2*mid)):printf("answer is %d",(2*mid+1));



}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote