Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- server
- programmers
- 따배씨
- php
- Math
- greedy
- 생활코딩
- Python
- 종만북
- udemy
- DP
- 정수론
- JavaScript
- sorting
- web
- Cleancode
- Algorithm
- 따라하며 배우는 C언어
- BFS
- Algospot
- C
- 백준
- 인프런
- graph
- 따라하면서 배우는 C언어
- String
- BOJ
- BASIC
- C언어
- dfs
Archives
- Today
- Total
몽상실현개발주의
[따배씨] 7.11 최대, 최소, 평균 구하기 예제 본문
따배씨 - 따라하며 배우는 C언어
7강 분기
7.11 최대, 최소, 평균 구하기 예제
#include <stdio.h>
#include <ctype.h>
#include <float.h>
int main(){
float min = FLT_MAX;
float max = -FLT_MIN;
float average;
float total = 0.0f;
float input;
int count = 0;
while (scanf("%f", &input) == 1)
{
max = (input > max) ? input : max;
min = (input < min) ? input : min;
total += input;
count++;
}
if (count > 0 && total != 0)
printf("Min = %f, Max = %f, Average = %f\n", min, max, total/count);
else
printf("Check input!");
return 0;
}
이 글의 모든 사진과 내용의 출처는 홍정모 교수님께 있음을 알려드립니다.
'Language > C' 카테고리의 다른 글
[따배씨] 8.1 입출력 버퍼 ~ 8.3 입출력 방향 재지정 (0) | 2021.05.26 |
---|---|
[따배씨] 7.13 goto 를 피하는 방법 (0) | 2021.05.24 |
[따배씨] 7.10 루프 도우미 continue 와 break (0) | 2021.05.24 |
[따배씨] 7.9 조건 연산자 (0) | 2021.05.24 |
[따배씨] 7.8 단어 세기 예제 (0) | 2021.05.24 |
Comments