프로그램 수정 좀 부탁드립니다ㅠㅠ
빛글
#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.
-------------------------------------------------
저렇게 출력이 되야되는데 이상하게 출력이 되요 ㅠ
어디가 잘못된건가요???
쓸건다쓴거 같은데 틀린곳을 모르겠어요 ㅠ
어디를 고쳐야지 출력문이 위에처럼 나오는지좀 알려주세요 부탁드릴께요 ㅠ ㅠ
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2704497 | int double char 같은것좀 좀만 더 가르쳐 주세요 (6) | 로지 | 2025-08-10 |
2704473 | 구조체 배열 초기화 질문 | 꽃은별 | 2025-08-10 |
2704445 | 배열과 조건문에 관한질문 (3) | 찬솔큰 | 2025-08-10 |
2704417 | 이진 트리 깊이 값 구하는것 질문입니다. | 푸른잎 | 2025-08-10 |
2704391 | 자료 유형에 관련된 문제입니다. (2) | 늘솜 | 2025-08-09 |
2704365 | c언어 문제안되서물어봅니다 (3) | 맑은가람 | 2025-08-09 |
2704338 | 다항식의 뺄셈에 대해 질문드립니다... (1) | 여자 | 2025-08-09 |
2704311 | 센서를 이용한 라인 주행인데 명령어좀 알려주세요 ㅠ_ㅠ (3) | 초록이 | 2025-08-09 |
2704284 | 배열for문;; (3) | 은솜 | 2025-08-08 |
2704255 | readline(int fd, char *buf, int nbytes)함수를 구현하는법좀..ㅠㅠ | 파라나 | 2025-08-08 |
2704196 | 간단한 c언어좀 만들어주세요 (2) | 슬S2아 | 2025-08-08 |
2704118 | 성적에서 등수 구하기 (4) | 딥레드 | 2025-08-07 |
2704062 | 알고리즘 알려주세요 | 나리 | 2025-08-06 |
2704035 | 답은 나오는데 과정에서 `` 약간 이상합니다.ㅎㅎ 답만나와버려요 | 핫블랙 | 2025-08-06 |
2703979 | 문자열 EEPROM 작성 방법 문의드립니다. | 그녀는귀여웠다 | 2025-08-06 |
2703954 | 키보드를 입력하면 캐릭터를 움직이기 질문 (7) | 좋아해 | 2025-08-05 |
2703924 | 계속 에러가... (4) | 눈꽃 | 2025-08-05 |
2703897 | 배열의 최댓값과 최솟값 차이 구하기 (1) | 하늬 | 2025-08-05 |
2703869 | C언어 질문입니다 급해용!!! ㅠㅠ (2) | 덕이 | 2025-08-05 |
2703814 | C로 프로그램을 만들때 도스창 말고 다르게 만드는방법이 있을까요? (2) | 소심한여자 | 2025-08-04 |