프로그램 수정 좀 부탁드립니다ㅠㅠ
빛글
#include stdio.h
#define MAX 31
enum temps_trends{rising=0, steady, falling=0, above, below, highest, lowest};
void print_temps(float temps[], int num);
void temps_extrema(float temps[], int num, float *max, float *min);
float temps_ave(float temps[], int num);
float temp(float temps[],int num);
float temps[MAX], ave=0, max, min;
int i, count, num=0;
void read_temps()
{
printf(매일의 기온의 입력하세요 : );
while(scanf(%f, &temps[num])==1)
{
num++;
if(numMAX)
{
printf(초과하였습니다.);
}
}
}
float temp(float temps[],int num)// 전날과 온도 비교 출력
{
if(i==0)
printf(\t);
else
{
if(temps[i]temps[i-1])
return temps_trends == 0;
else if(temps[i]temps[i-1])
return rising;
else
printf(\t\t);
}
}
void temp_mn(float temps[], int num)
{
if(temps[i] ave)
printf(above ave.\t);
else if(temps[i] ave)
printf(below ave.\t);
else
printf(\t);
printf(\n);
}
void temp_temps(float temps[], int num)
{
if(temps[i]==max)
printf(highest\n);
else if(temps[i]==min)
printf(lowest\n);
else
printf(\n);
}
float temps_ave(float temps[], int num)
{
float total=0;
int count;
for(count=0; countnum; count++)
{
total = total + temps[count];
}
ave = total/num;
return ave;
}
void temps_extrema(float temps[], int num, float *max, float *min)
{
*max = temps[0];
*min = temps[0];
for(i=1; inum-1; i++)
{
if(temps[i] *max)
*max = temps[i];
if(temps[i] *min)
*min = temps[i];
}
}
void print_temps(float temps[],int num)
{
for(i=0; inum; i++)
{
printf(%.1f\t, temps[i]);
temp(temps, i);
temp_mn(temps, i);
temp_temps(temps, i);
}
}
void main()
{
read_temps();
ave=temps_ave(temps, num);
temps_extrema(temps, num, &max, &min);
print_temps(temps, num);
}
--------------------------------------------------------
입력: 27.5 26.5 28.0 29.0 25.0 30.0 32.5 29.5^D
(^D는 Ctrl 키와 D키를 동시에 누르는 것을 의미하며, 파일의 끝(EOF)을 나타낸다.)
출력:
27.5 below ave.
26.5 falling below ave.
28.0rising below ave.
29.0rising above ave.
25.0 fallingbelow ave. lowest
30.0 rising above ave.
32.5 rising above ave. highest29.5falling above ave.
-------------------------------------------------
저렇게 출력이 되야되는데 이상하게 출력이 되요 ㅠ
어디가 잘못된건가요???
쓸건다쓴거 같은데 틀린곳을 모르겠어요 ㅠ
어디를 고쳐야지 출력문이 위에처럼 나오는지좀 알려주세요 부탁드릴께요 ㅠ ㅠ
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2698909 | 서비스 요청 고객 관리 프로그램 짜는것좀 도와주세요ㅜㅜ (4) | 궁수자리 | 2025-06-21 |
2698882 | 프로그래밍좀 짜주세요 (3) | 황예 | 2025-06-21 |
2698855 | 카프-라빈 알고리즘 코딩 분석좀 도와주세요.. | 꽃봄 | 2025-06-20 |
2698829 | 학점계산기 (7) | MyWay | 2025-06-20 |
2698782 | 기초적인 함수 질문이요ㅠㅠㅠㅠ | 내담 | 2025-06-20 |
2698749 | 프로그램 짜던 도중 패닉입니다...ㅜ | 파랑 | 2025-06-19 |
2698719 | 조건부컴파일 질문입니다.~ (2) | 큐트 | 2025-06-19 |
2698693 | 재귀 함수 에러 | 바닐라 | 2025-06-19 |
2698673 | 고민이있는데 들어좀주세요!! (1) | 초코맛캔디 | 2025-06-19 |
2698644 | 1부터 n까지의 합을 구하는데 엄청긴숫자의 합을 구할때는 어떻게 해야하나요? (4) | 슬우 | 2025-06-18 |
2698616 | 다른 함수로 안넘어갑니다..;;; | 도1도캣 | 2025-06-18 |
2698587 | 배열하다 막혀서... (3) | WhiteCat | 2025-06-18 |
2698559 | 문자열을 비우는방법 (2) | 하늘 | 2025-06-18 |
2698528 | 착하고 친절한 선생씌구해염~ㅋㅋ (4) | 옆집언니야 | 2025-06-17 |
2698502 | 자료구조 큐 | 캔서 | 2025-06-17 |
2698477 | 실행화면 배경문의요 | 선아 | 2025-06-17 |
2698430 | 변수의 값이 저장이 않되네요;; (4) | 피네 | 2025-06-16 |
2698404 | C#을 배울려고 하는데 C나 C++을 알아야 하나요 ?? (1) | 신당 | 2025-06-16 |
2698342 | 프로그램 질문점녀 (4) | 데빌의눈물 | 2025-06-16 |
2698318 | 파일 입출력 질문입니다~ (2) | 꽃 | 2025-06-15 |