소스 수정 질문입이다
good
#include stdio.h
#define Array 31
enum temps_trends{
falling = 0,
rising,
steady,
nothing
};
typedef enum temps_trends temps_trends;
void read_temps(float temps[],int *num);
void print_temps(float temps[],int num);
float temps_ave(float temps[],int num);
void temps_extrema(float temps[],int num,float *max,float *min);
temps_trends trends(float temps[],int i);
int main(void)
{
float temps[Array] = {0,};
int num_temps = 0;
read_temps(temps,&num_temps);
print_temps(temps,num_temps);
return 0;
}
void read_temps(float temps[],int *num){
printf(온도를 입력하세요^^:);
while(1){
if(*num Array){ /////////////////////////////이 부분을 수정하면 될것같은데 도통 감이 않오네요;;
if(scanf(%f,&temps[(*num)++] ) == EOF )
break;
}
else{
printf(더이상 입력이 불가능합니다.\n);
break;
}
}
}
void print_temps(float temps[],int num){
float Max,Min,Ave;
int count;
if(num 1){
Ave = temps_ave(temps,num);
}
else
Ave = temps[0];
temps_extrema(temps,num,&Max,&Min);
printf(Ave : %4f\n, temps_ave(temps,num) );
for(count = 0; count num-1 ; count++){
printf(%4.1f\t,temps[count]);
switch(trends(temps,count)){
case falling:
printf(falling\t);
break;
case rising:
printf(rising\t);
break;
case steady:
printf(steady\t);
break;
default :
printf(\t);
}
if(temps[count] Ave)
printf(above ave.);
else if(temps[count] Ave)
printf(below ave.);
else
printf(\t);
printf(\n);
}
printf(\nMax : %4.1f\tMin : %4.1f\n,Max,Min);
}
float temps_ave(float temps[],int num){
int count;
float total = 0;
for (count = 0; count num ; count++){
total = total + temps[count];
}
return (total / num);
}
void temps_extrema(float temps[],int num,float *max,float *min){
int i;
*max = temps[0];
*min = temps[0];
for(i = 1; i num - 1; i++){
if(temps[i] *max)
*max = temps[i];
if(temps[i] *min)
*min = temps[i];
}
}
temps_trends trends(float temps[],int i){
if(i){
if( temps[i] temps[i-1] )
return falling;
else if( temps[i] temps[i-1] )
return rising;
return steady;
}
return nothing;
}
출력이 입력한 만큼만 되야하는데 31개까지 다 출력이 되는데요
어디를 고쳐야지 되는지 모르겠어요 ㅠ
알려주세요~~~~~~
-
연연두
수정했습니다ㅠ ㅠ
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2695766 | 달팽이 배열 어디서 틀렸는지 모르겠습니다ㅠㅠ | 연분홍 | 2025-05-23 |
2695738 | fopen과fclose질문~~ (5) | 희선 | 2025-05-23 |
2695707 | 3의 배수 나타내기. (2) | 수리 | 2025-05-23 |
2695626 | 피보나치수열 과제 때문에 질문 드립니다. (6) | 옆집언니 | 2025-05-22 |
2695595 | 포인트공부중입니다 int형에서 4=1 인가요? (3) | 족장 | 2025-05-22 |
2695567 | 드라이브 고유번호를 가져오는 함수 (2) | 초코맛사탕 | 2025-05-21 |
2695533 | 음수의 산술변환! 질문이요 ㅠㅠ... (4) | 꽃여름 | 2025-05-21 |
2695506 | 구조체 배열 이용 도서목록 출력 프로그램 (1) | 가을귀 | 2025-05-21 |
2695450 | c언어 함수 질문이요.... | 이슬비 | 2025-05-20 |
2695403 | VirtualAlloc함수 및 메모리 질문 | 크리에이터 | 2025-05-20 |
2695355 | c언어 for함수 | 미쿡 | 2025-05-19 |
2695327 | 안녕하세요 제가 이번에 좀 큰 프로그램을.. | 악당 | 2025-05-19 |
2695295 | mutex동기화의 thread기반 채팅 서버소스 질문입니다 | 그루터기 | 2025-05-19 |
2695270 | 질문이요..swap 관한겁니다..ㅠㅠ (3) | 콩알녀 | 2025-05-19 |
2695244 | 노땅초보궁금한게 하나 있는데요..반복문(while문)초보자질문 (6) | 큰꽃늘 | 2025-05-18 |
2695166 | do while 문 어떤것이잘못된건지 모르겠어요 (2) | 아이폰 | 2025-05-18 |
2695122 | 구조체에 대해 물어보고 싶은게 있습니다 ^^^.. (7) | 수련 | 2025-05-17 |
2695091 | txt 파일 입출력 후 2차 배열에 저장하기입니다. (3) | 헛장사 | 2025-05-17 |
2695063 | 수도요금 프로그램좀 짜주세요. | 시내 | 2025-05-17 |
2695033 | 답변좀요ㅠㅠ (1) | 비사벌 | 2025-05-16 |