성적처리프로그램 질문합니다 :-) !!
움찬
선택정렬과 이진탐색을 이용해서 푸는 문제인데.. 여기까지 하고 작성했는데
그다음부터 어떻게 하죠ㅠㅠ
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];
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2654881 | PID 모듈 검색 부분 질문합니다 . | 이름없음 | 2024-05-14 |
2654850 | 조건에 만족하는 다음 수를 찾고 싶습니다. | 초엘 | 2024-05-14 |
2654790 | 두파일간 byte단위 txt파일 복사 中 | 슬찬 | 2024-05-14 |
2654768 | 사전만들기 입니다. | 여우By | 2024-05-13 |
2654716 | c언어 고수님들 답좀적어주세요 급합니다 ㅠㅠ | 한말글 | 2024-05-13 |
2654688 | c언어 ㅠㅠ 너 무 어려 워요 ㅠ 도와주세요!! | 별빛 | 2024-05-13 |
2654659 | 구구단 소스 궁금한 점 도움 부탁드립니다! (2) | 미련곰팅이 | 2024-05-12 |
2654633 | 오류가 무었인가요..? (2) | 단순랩퍼 | 2024-05-12 |
2654603 | 어디가 잘못된지를 모르겠습니다. 한 번 봐주세요...ㅠ (2) | 글고운 | 2024-05-12 |
2654574 | 소스 추가좀 부탁드립니다. (등수 출력) | 크리미걸 | 2024-05-12 |
2654550 | 피보나치수열. (3) | 중독적 | 2024-05-11 |
2654521 | c초보 빙고관련게임... | 달콤이 | 2024-05-11 |
2654491 | 10진수를 2진수로 바꾸는법 (8) | 아잉 | 2024-05-11 |
2654412 | 빅오를 구하고 싶어요~ | 애기 | 2024-05-10 |
2654381 | 혼자 연구하는 c/c++ 질문 | 아잉 | 2024-05-10 |
2654352 | 행렬크기를 scanf로 입력받을수도 있나요..? | VanilLa | 2024-05-10 |
2654293 | 첫시작값과 끝값의 사이에 존재하는 정수들의 합을 구하는 것 (5) | 해긴 | 2024-05-09 |
2654185 | 64bit 환경에서 자료형의 크기가 좀궁그해요(완료) 더궁금한게 생겻어요(추가) (2) | 빈길 | 2024-05-08 |
2654152 | 확장자 exe로 변경 (1) | 한 | 2024-05-08 |
2654128 | c언어 간단하게 자판기만들려는데 ㅜㅜ | 유1혹 | 2024-05-08 |