프로그램 수정 좀 부탁드립니다ㅠㅠ
빛글
#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.
-------------------------------------------------
저렇게 출력이 되야되는데 이상하게 출력이 되요 ㅠ
어디가 잘못된건가요???
쓸건다쓴거 같은데 틀린곳을 모르겠어요 ㅠ
어디를 고쳐야지 출력문이 위에처럼 나오는지좀 알려주세요 부탁드릴께요 ㅠ ㅠ
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |
2691483 | 파일 오픈시 에러 질문드립니다. (2) | 호습다 | 2025-04-14 |
2691450 | [visual c++ 툴]기초 질문 (3) | 해긴 | 2025-04-13 |