Skip to content

0721_safe_Kang040429.c #984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

0721_safe_Kang040429.c #984

wants to merge 2 commits into from

Conversation

Kang040429
Copy link

#include <stdio.h>

float maxAmount(float, float, float);
int main() {
float ABC[3];
float ijk[3];
float divisor = 0;
float max_product = 0;

scanf("%f %f %f", &ABC[0], &ABC[1], &ABC[2]);
scanf("%f %f %f", &ijk[0], &ijk[1], &ijk[2]);

max_product = ABC[0];
for (int i = 0; i <= 2;i++) {
	max_product = maxAmount(max_product, ABC[i], ijk[i]);
}

for (int i = 0; i <= 2;i++) {
	ABC[i] = ABC[i]-ijk[i]*max_product;

	if (ABC[i] - (int)ABC[i] < 0.00001) {
		printf("%d ", (int)ABC[i]);
	}
	else {
		printf("%f ", ABC[i]);
	}		
}	

}

float maxAmount(float a, float c, float d) {
if (a < c/d) {
return a;
}
else {
return c/d;
}
}

@Kang040429 Kang040429 closed this Jul 22, 2025
@Kang040429 Kang040429 reopened this Jul 22, 2025
@Kang040429 Kang040429 closed this Jul 22, 2025
@Kang040429 Kang040429 reopened this Jul 22, 2025
@Kang040429 Kang040429 closed this Jul 22, 2025
@Kang040429 Kang040429 reopened this Jul 22, 2025
@Kang040429 Kang040429 changed the title 0721_1_Kang040429.c 0722_2_Kang040429.c Jul 22, 2025
@Kang040429 Kang040429 changed the title 0722_2_Kang040429.c 0721_1_Kang040429.c Jul 22, 2025
@Kang040429 Kang040429 closed this Jul 22, 2025
@Kang040429 Kang040429 reopened this Jul 22, 2025
@Kang040429 Kang040429 changed the title 0721_1_Kang040429.c 0722_2_Kang040429.c Jul 22, 2025
@Kang040429 Kang040429 changed the title 0722_2_Kang040429.c 0721_safe_Kang040429.c Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant