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);
이렇게 잡았습니다.
코딩을 하면 디버그가 안떠서 재대로 된줄알았는데..
코딩하니 계속하시려면 아무키나 누르십시오 라는 메시지만 뜨내요....
소스에 잘못 된부분을 좀 알려주세요 ㅠ.ㅠ
그리고 함수의 매개변수를 외부 변수를 통하여 전달하도록 변경하려면 어떻게 해야되는지도 부탁드립니다..
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |
2700041 | 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? | 헛장사 | 2025-07-01 |
2700012 | 배열// (1) | 전갈자리 | 2025-07-01 |
2699895 | 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) | 선아 | 2025-06-30 |
2699842 | 질문을 너무 많이 하네여.....죄송.... (2) | 해님꽃 | 2025-06-29 |
2699816 | 오류 질문입니다.. (1) | 해비치 | 2025-06-29 |
2699763 | 질문입니다 ! 꼭 좀 도와주세요ㅠㅠ (2) | 미라 | 2025-06-28 |
2699555 | c언어 다항식을 입력을 했는데 왜 출력이 안될까요? | 피스케스 | 2025-06-27 |
2699528 | C언어 포인터연산 질문입니다. (3) | 안녕나야 | 2025-06-26 |