성적처리프로그램 질문합니다 :-) !!
움찬
선택정렬과 이진탐색을 이용해서 푸는 문제인데.. 여기까지 하고 작성했는데
그다음부터 어떻게 하죠ㅠㅠ
1. 40명의 성적을 무작위로 생성하여 성적을 부여하는 프로그램을 작성하도록 한다.
2. 과목은 수학으로 하고, 각 학생의 정보는 ID와 성적으로 이루어진다.
3. ID는 처음 학생부터 순서대로 1~40까지로 부여한다.
4. 성적은 중간고사, 기말고사, 과제, 출석, 학점으로 이루어진다.
5. 중간고사, 기말고사는 각 0~100 사이의 수로 무작위로 생성하며, 30%씩 성적에 반영된다.
6. 과제는 0~100 사이의 수로 무작위로 생성하며, 20% 성적에 반영된다.
7. 출석은 0~20 사이의 수로 성적에 그대로 반영되어 최종성적에 더해진다.
8. 반영되는 성적은 소숫점을 포함한 성적으로 반영한다.
9. 학점은 상대평가로 이루어지며, A, B, C, D가 각각 10명씩이다.
10. 출석이 0점인 사람은 F학점을 부여한다. F학점 학생들은 상대평가에서 제외하고 순위를 매겨야 한다. 즉, A~C는 각각 10명이 되고 D학점과 F학점의 학생수가 10명이 된다.#include stdio.h
#include stdlib.h
#include time.h
#define MAX_ARY_SIZE 40
int seqSearch (int list[], int last, int target, int* locn);
int binarySearch (int list[], int last, int target, int* locn);
void selectionSort (int id[], int score[], int last);
//void printArray(int id[], int score[], int n);
int main (void)
{
int i;
int menu;
int locn;
int target;
int id[MAX_ARY_SIZE];
int score[MAX_ARY_SIZE];
srand((unsigned)time(NULL));
for(i=0; i MAX_ARY_SIZE; i++)
{
id[i] = 2013001+i;
score[i] = rand() % 101;
}
/*for(i=0; i MAX_ARY_SIZE; i++)
{
printf(%d\t%d\n, id[i], score[i]);
}*/ while(1)
{
printf(1. ID검색\n);
printf(2. 성적순\n);
printf(1. 종료\n);
printf(메뉴선택 : );
scanf(%d, &menu); if(menu == 1)
{
printf(id를 입력하시오:);
scanf(%d, &target);
if(binarySearch(id, MAX_ARY_SIZE-1, target, &locn))
{
printf(%d\t%d\n, id[locn], score[locn]re[locn]);
}
} else if(menu ==2)
{
selectionSort(id, score, MAX_ARY_SIZE-1);
printf(정렬 \n);
for(i=0; i MAX_ARY_SIZE; i++)
{
printf(%d\t%d\n, id[locn], score[locn]);
}
}
else if(menu ==7)
{
break;
}
}
void selectionSort (int ld[], int score[], int last)
{
int max;
int tempScore;
int tempId;
int current;
int walk;
for (current = 0; current last; current++)
{
max = current; for (walk = current + 1;
walk = last;
walk++) if (score[walk] score[max])
max = walk; tempId = id[current];
id[current] = id[max];
id[max] = tempId; tempId = score[current];
score[current] = score[max];
score[max] = tempScore;
}
return;
} printf(\n\nEnter a key for search : );
scanf(%d, &target);
while(1)
{
printf(1. ID검색\n);
printf(2. 성적순\n);
switch(target)
{
case 1:
printf(ID검색 소스 \n);
case 2:
printf(성적순 소스 \n);
case 7:
exit;
} /*if (binarySearch (id, MAX_ARY_SIZE -1, target, &locn))
printf(%3d found at location:%2d\n, id[locn], score[locn]);
else
printf(%3d NOT found at locn\n);
printf(Enter next key -1 to quit: ); */
scanf(%d, &target);
} printf(End of search. \n);
return 0;
} int seqSearch (int list[], int last, int target, int* locn)
{
int looker;
looker = 0;
while (looker last && target != list[looker])
looker++;
*locn = looker;
return (target == list[looker]);
} int binarySearch (int list[], int end, int target, int* locn)
{
int first;
int mid;
e:pre int last; first = 0;
last = end;
while (first = last)
{
mid = (first + last) / 2;
if (target list[mid])
first = mid + 1;
else if (target list[mid])
last = mid - 1;
else
first = last + 1;
}
*locn = mid;
return target == list [mid];
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2694370 | 내일까진데 함수호출 제발 도와주세요!!!!!!!!!11 | 들찬 | 2025-05-10 |
2694339 | putchar()의 괄호 안에 int c=10;로 전에 선언된 c를 넣으면 안되는 이유에서 제가 생각한 것이 그 이유가 되는지 확인하고 싶습니다. (3) | 미르 | 2025-05-10 |
2694316 | 이 코드 어디가 잘못되었는지 고수분들 ㅠㅠ (2) | 나빛 | 2025-05-10 |
2694285 | 언어 공부하는 과정 좀 추천해주세요! (1) | 아빠몬 | 2025-05-09 |
2694258 | 카운터.. 질문입니다. (4) | 하늘빛눈망울 | 2025-05-09 |
2694229 | 단순한 질문이요 (8) | 여름 | 2025-05-09 |
2694202 | 용돈을 가지고 할 수 있는 일을 여러가지로 출력하는 방법 좀 알려주세요! (2) | 미나 | 2025-05-09 |
2694145 | 화면깜빡임을 없애고 싶은데요... (1) | 어서와 | 2025-05-08 |
2694069 | unsigned 질문입니다. | 힘차 | 2025-05-07 |
2694012 | 전공 비전공자 개발자 (10) | 말글 | 2025-05-07 |
2693984 | 오버로딩이 무엇인가요? (2) | 헛매질 | 2025-05-07 |
2693956 | PlaySound재생이 안됩니다!(C에 음악넣기) | 지존 | 2025-05-06 |
2693928 | &와 *의 사용에 관한 명확한 이해 | 제나 | 2025-05-06 |
2693903 | 반복문 설명좀요 ㅠㅠ (2) | 란새 | 2025-05-06 |
2693869 | stdio.h 는 왜 쓰는건가요? (1) | 큰꽃들 | 2025-05-06 |
2693842 | 포인터 변수의 주소값끼리 더하는 것에 대해서 질문드립니다. (1) | 진솔 | 2025-05-05 |
2693811 | 소수 출력;;;; | 화이트캣 | 2025-05-05 |
2693788 | 이런 함수는 없나요? (3) | 앤드류 | 2025-05-05 |
2693758 | txt파일 불러와서 행렬로 저장 | 큰애 | 2025-05-05 |
2693727 | scanf 오류 문제!! (2) | 큰나래 | 2025-05-04 |