풀이


정말 고등학교 1년만 제대로 다니면 누구나 풀 수 있는 몇 안 되는 문제가 아닐까싶다.


소스 코드


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <math.h>
int d(int n) {
    if(n%2==0return 1;
    else return 0;
}
int main() {
    int a, b, c, q1, q2;
    double p,q;
    scanf("%d %d %d",&a,&b,&c);
    if (b*- 4 * a*> 0) {
        q1 = (-+ (int)sqrt(b*- 4 * a*c)) / (2 * a);
        q2 = (-- (int)sqrt(b*- 4 * a*c)) / (2 * a);
        p = ((-+ sqrt(b*- 4 * a*c)) / (2 * a)) - q1;
        q = ((-- sqrt(b*- 4 * a*c)) / (2 * a)) - q2;
        if (p || q) printf("둘다틀렸근"); 
        else if (d((-+ (int)sqrt(b*- 4 * a*c)) / (2 * a))&&d((-- (int)sqrt(b*- 4 * a*c)) / (2 * a))) printf("이수근");
        else printf("정수근");
    }
    else {
        printf("둘다틀렸근");
    }
    return 0;
}
cs

+ Recent posts