It's a program that outputs the second largest integer when you receive the cleaning number I think it's going well and there's no error, but I keep getting wrong answers. Please tell me what's wrong
#define _CRT_SECURE_NO_WARNINGS
#include<stdlib.h>
#include<stdio.h>
int main() {
int x, y, z=0;
printf ("Enter 3 integers: ");
scanf("%d %d %d", &x, &y, &z);
if ((1 <= x, y, z) && (x, y, z <= 100)) {
if (((x > y) && (z > y) && (x < z)) || ((x > z) && (y > z) && (x < y)) || ((y == z) && (x < y)) || ((x == y) && (x < z)) || ((x == z) && (x < y)))
printf("%d", x);
else if (((x > y) && (z > y) && (z < x)) || ((y > x) && (z > x) && (z < y)) || ((x == y) && (z < y)) || ((y == z) && (z < x)) || ((x == z) && (z < y)))
printf("%d", z);
else if (((y > x) && (z > x) && (y < z)) || ((x > z) && (y > z) && (y < x)) || ((x == z) && (y < x)) || ((y == x) && (y < z)) || ((y == z) && (y > z)))
printf("%d", y);
else printf("%d", x);
}
else printf ("Please re-enter")
return 0;
}
If you do this, you get the second largest number when you enter all three integers, but Baekjun keeps saying that it's wrong.What do you want?
c++
if ((1 <= x, y, z) && (x, y, z <= 100))
The intention would be x, y, and z in the range between 1 and 100, respectively, and it wouldn't work. No compilation errors or warnings?
If I were you, I would make three corrections
1. What if there are overlapping numbers among the three counts?
2. Do not receive back to scanf when "re-enter" appears
If one or more variables other than 3.x, y, and z are added, the code correction increases->for statement may be intended to be more general...?
529 Uncaught (inpromise) Error on Electron: An object could not be cloned
547 PHP ssh2_scp_send fails to send files as intended
697 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
546 Understanding How to Configure Google API Key
546 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.