c언어 질문드립니다...
도리도리
질문 제목 : 프로젝트로 파일을 나눴는데 다른파일을 못 읽는거 같습니다.질문 요약 :프로젝트로 파일을 나눴는데 다른파일을 못 읽는거 같습니다.질문 내용 :
C언어를 배우는 학생입니다..
학교 숙제로.... 받은 소스를 가지고....
데이터를 입력하는 부분을 위한 input( )함수로 데이터를 처리하는 부분을 위한 process( ) 함수를 정의해서 3개의 파일로 1개의 프로그램을 만들라는
내용인데....
아래 소스입니다..
#include stdio.h
#include stdlib.h
#define SIZE 7
#define UPPER 100.0
#define LOWER 60.0
int main(void)
{
float data[SIZE];
float total = 0.0, max = 0.0, min = UPPER;
int man;
float score;
printf(\n\t\t 체조 경기장의 점수 산정 프로그램 );
man = 0;
while (man SIZE)
{
printf(\n\t\t\t 제 %d 채점관 : , man + 1);
scanf(%f, &data[man]);
if (data[man] = LOWER && data[man] = UPPER)
man++;
else
printf( ERROR : 점수는 60점 - 100점 사이\a\a\a\n);
}
for (man = 0; man SIZE; man++)
total += data[man];
for (man = 0; man SIZE; ++man)
{
if (max data[man])
max = data[man];
if (min data[man])
min = data[man];
}
total = total - (max + min);
score = (float) total / (SIZE - 2);
for (man = 0; man SIZE; man++)
{
printf(\n\t %d 채점관 = %.2f, man + 1, data[man]);
}
printf(\n\t 최고 점수 : %.2f, max);
printf(\n\t 최하 점수 : %.2f, min);
printf(\n\t 점수 총계 : %.2f, total);
printf(\n\t 평 균 : %.2f\n, score);
system(PAUSE);
}제가 데이터를 입력하는 input 부분을...
extern int man;
void input(float data[SIZE], float total, float max, float min, float score)
{
man = 0;
while (man SIZE)
{
printf(\n\t\t\t 제 %d 채점관 : , man + 1);
scanf(%f, &data[man]);
if (data[man] = LOWER && data[man] = UPPER)
man++;
else
printf( ERROR : 점수는 60점 - 100점 사이\a\a\a\n);
for (man = 0; man SIZE; man++)
{
printf(\n\t %d 채점관 = %.2f, man + 1, data[man]);
}
printf(\n\t 최고 점수 : %.2f, max);
printf(\n\t 최하 점수 : %.2f, min);
printf(\n\t 점수 총계 : %.2f, total);
printf(\n\t 평 균 : %.2f\n, score);
}
}
이렇게 잡았고...
데이터를 처리하는 process부분을...
extern int man;
float process(float data[SIZE], float *total, float *max, float *min)
{
float score;
for (man = 0; man SIZE; man++)
*total += data[man];
for (man = 0; man SIZE; ++man)
{
&nbnbsp; if (*max data[man])
*max = data[man];
if (*min data[man])
*min = data[man];
}
*total = *total - (*max + *min);
score = (float) *total / (SIZE - 2);
return(score);
}
이렇게 잡았습니다..
그리고 메인부분을
int man;
int main(int argc, char *argv[])
{
float data[SIZE];
float total = 0.0, max = 0.0, min = UPPER;
float score;
input(data, total, max, min, score);
score = process(data, &total, &max, &min);
system(PAUSE);
return 0;
}
이렇게 잡았고
헤더는
#include stdio.h
#include stdlib.h
#define SIZE 7
#define UPPER 100.0
#define LOWER 60.0
float process(float data[SIZE], float *total, float *max, float *min);
void input(float data[SIZE], float total, float max, float min, float score);
이렇게 잡았습니다.
코딩을 하면 디버그가 안떠서 재대로 된줄알았는데..
코딩하니 계속하시려면 아무키나 누르십시오 라는 메시지만 뜨내요....
소스에 잘못 된부분을 좀 알려주세요 ㅠ.ㅠ
그리고 함수의 매개변수를 외부 변수를 통하여 전달하도록 변경하려면 어떻게 해야되는지도 부탁드립니다..
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692374 | 고수님들 댓글 마니부탁해요!!! (2) | 엄지 | 2025-04-22 |
2692343 | scnaf에 자꾸 선언을 참조하라는데;; (8) | 도래 | 2025-04-22 |
2692282 | 도스상에서 생성된 exe파일에 press~ 뜨게 하기 (4) | 회사원 | 2025-04-21 |
2692256 | scanf("%*c"); ㅠㅠ 고수님들 | 거북이 | 2025-04-21 |
2692230 | 하노이탑 질문입니다. (1) | 미쁘다 | 2025-04-21 |
2692210 | 정보 올림피아드 문제인데.. 풀이 과정이 궁금합니다.(재귀함수) (5) | 물티슈 | 2025-04-20 |
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 |