Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

브래의 슬기로운 코딩 생활

C 언어 12주차 복습과제 본문

1-1/C프로그래밍

C 언어 12주차 복습과제

김브래 2022. 5. 28. 17:33

7.10


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h >
int main(void)
{
    float w=0,h=0;
    printf("BMI지수를 계산 하는 프로 그램 입니다\n");
    printf("체중과 키를 입력해 주세요.(kg. m)\n");
    scanf("%f %f", &w, &h);
    float BMI = w / (h * h);
    printf("당신의 BMI지수는 %.1f 입니다.", BMI);
    if (BMI >= 30) {
        printf("당신은 고도비만 입니다.");
    }
    else if (BMI >= 25 && BMI < 30) {
        printf("당신은 비만 입니다.");
    }
    else if (BMI >= 23 && BMI < 25) {
        printf("당신은 과체중 입니다.");
    }
    else if (BMI >= 18.6 && BMI < 23) {
        printf("당신은 정상 입니다.");
    }
    else if (BMI <= 18.5) {
        printf("당신은 저체중 입니다.");
    }
    else
    return 0;
}

7.11


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h >
int main(void)
{
    int x , y , z , i , c = 1;
    printf("직각 삼각형의 밑변, 높이, 빗변을 X, Y, Z로 할 때\n");
    printf(" X2+Y2=Z2을 만족하는 자연수를 피타고라스 수라고 합니다.\n");
    printf("자연수 어디까지 피타고라스 수 조합을 찾고 싶습니까?\n");
    scanf("%d", &i);

    for (x = 1; x <= i; x++) {
        for (y = 1; y <= i; y++) {
            for (z = 1; z <= i; z++) {
                if (x * x == y * y + z * z) {
                    printf("%3d= %3d %3d %3d \n", c, x, y, z);
                        c++;
                }
            }
        }
    }
        return 0;


7.12


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h >
int main(void)
{
    int x , y , z , i , c = 1;
    printf("직각 삼각형의 밑변, 높이, 빗변을 X, Y, Z로 할 때\n");
    printf(" X2+Y2=Z2을 만족하는 자연수를 피타고라스 수라고 합니다.\n");
    printf("몇개의 피타고라스 수 조합을 찾고 싶습니까?\n");
    scanf("%d", &i);

    for (x = 1; x <= 10000; x++) {
        for (y = 1; y <= 10000; y++) {
            for (z = 1; z <= 10000; z++) {
                if (x * x == y * y + z * z) {
                    printf("%3d= %3d %3d %3d \n", c, x, y, z);
                    c++;
                }
                if (c == i+1) {
                    goto END;
                }
            }
        }
    }
    END:
        return 0;
}  

1.

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h >
int main(void)
{
    int m = 0;
    for (;;) {
        printf("월을 입력하세요.");
        scanf("%d", &m);
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
            printf("31일\n");
        else if (m == 4 || m == 6 || m == 9 || m == 11)
            printf("30일\n");
        else if (m = 2)
            printf("28일(윤년은 29일)\n");
        else
            printf("다시 입력하세요.\n");
    }
        return 0;
}  

'1-1 > C프로그래밍' 카테고리의 다른 글

C언어 기말고사 정리  (0) 2022.06.16
C언어 13주차 예습 과제  (0) 2022.06.01
C언어 12주차 예습 과제  (0) 2022.05.25
C언어 11주차 복습 과제  (0) 2022.05.21
C언어 11주차 예습 과제  (0) 2022.05.18