Last active
April 7, 2021 10:48
-
-
Save seia-soto/82c9b6139538ebc71159bceb872bfe0d to your computer and use it in GitHub Desktop.
청명고등학교 시스템 프로그래밍 4월 7일 미션
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
char gender; | |
float tall; | |
float weight; | |
printf("성별을 입력하세요: [f/m] "); | |
scanf("%c", &gender); | |
printf("키를 입력하세요: [170] "); | |
scanf("%f", &tall); | |
printf("몸무게를 입력하세요: [65] "); | |
scanf("%f", &weight); | |
float kWeight; | |
if (gender == 'm') { | |
kWeight = tall * tall * 0.0022; | |
} else { | |
if (gender != 'f') { | |
printf("올바르지 않은 성별 코드가 전달되어 여성을 기준으로 표준 체중을 계산합니다...\n"); | |
} | |
kWeight = tall * tall * 0.0021; | |
} | |
printf("표준 체중(kWeight): %.2f\n", kWeight); | |
float bmi = ((weight - kWeight) / kWeight) * 100; | |
printf("현재 BMI 지수: %.2f\n", bmi); | |
printf("현재 체중은 "); | |
switch ((int) bmi / 10) { | |
case 0: | |
printf("정상"); | |
break; | |
case 1: | |
printf("과체중"); | |
break; | |
case 2: | |
printf("비만"); | |
break; | |
default: | |
printf("가능한 범위 밖"); | |
} | |
printf("입니다."); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int a, b, c, max; | |
printf("세 수를 입력하세요: [1 5 4] "); | |
scanf("%d %d %d", &a, &b, &c); | |
max = a; | |
if (b > max) max = b; | |
if (c > max) max = c; | |
printf("가장 큰 수는 %d입니다."); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int month; | |
printf("월의 날수를 구하기 위해 구하려는 월을 입력해주세요: [1-12] "); | |
scanf("%d", &month); | |
if (month > 12 || month < 1) { | |
printf("잘못된 달 범위를 입력하여 1월로 처리합니다...\n"); | |
month = 1; | |
} | |
int days = 0; | |
if (month == 2) { | |
days = 28; | |
} | |
if (month <= 7) { | |
if (month % 2) { | |
days = 31; | |
} else { | |
days = 30; | |
} | |
} else { | |
if (month % 2) { | |
days = 30; | |
} else { | |
days = 31; | |
} | |
} | |
printf("%d월은 %d일까지 있습니다.", month, days); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int year; | |
printf("윤년인지 구할 연도를 입력해주세요: [0-2^32-1] "); | |
scanf("%d", &year); | |
if (year < 1) { | |
printf("입력하신 연도가 0보다 작아 1년으로 처리합니다...\n"); | |
year = 0; | |
} | |
if (!(year % 400) || (!(year % 4) && year & 100)) { | |
printf("%d년은 윤년입니다.", year); | |
} else { | |
printf("%d년은 평년입니다.", year); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main () { | |
for (int i = 1; i <= 5; i++) { | |
for (int j = 0; j < 5; j++) { | |
printf("%d ", i); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
for (int i = 0; i < 5; i++) { | |
for (int i = 1; i <= 5; i++) { | |
printf("%d ", i); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment