성적처리프로그램 질문합니다 :-) !!
움찬
선택정렬과 이진탐색을 이용해서 푸는 문제인데.. 여기까지 하고 작성했는데
그다음부터 어떻게 하죠ㅠㅠ
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];
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2695010 | C++의 STL은 왜 굳이 템플릿화 시켜서 라이브러리를 만드나요? (초보수준의 질문..) (2) | 엘보어 | 2025-05-16 |
2694958 | 로직이 변한다는 것에 대해서 궁금합니다. | 튼동 | 2025-05-16 |
2694929 | 열혈강의 25-2 두번째 문제 질문 | 지우개 | 2025-05-15 |
2694900 | dequeue 에서 리턴값 프린트 방법알려주세요 오늘 12시까지 대화방에 있습니다 도와주세요 | 미투리 | 2025-05-15 |
2694854 | 절대값을 구할때 (2) | 그녀는귀여웠다 | 2025-05-15 |
2694827 | 이제 어떻게 공부해야할지 모르겠네요 | 새얀 | 2025-05-14 |
2694778 | 순열 계산요. | 맛조이 | 2025-05-14 |
2694754 | ShowWindow 함수를 이용하려 하는데 질문있습니다. (2) | 파도 | 2025-05-14 |
2694731 | 리눅스 커널의 시작점 질문 | 미르 | 2025-05-13 |
2694702 | 이거 뭐가문제인가요 코드수정좀 (3) | 맑은 | 2025-05-13 |
2694675 | C언어 후위표기를 중위표기로 | 앨런 | 2025-05-13 |
2694646 | 안녕하세요 파일 합치기 함수! (1) | 연블루 | 2025-05-13 |
2694618 | 잘몰라서 설명부탁드립니다. scanf 관련 (3) | 파라 | 2025-05-12 |
2694590 | 이 코드가 뭐하는 코드일까요? #2 | 빵순 | 2025-05-12 |
2694559 | 동적할당으로 배열(2차원열)을 만드는데 있어 그걸 함수화시키는데... (1) | 늘솔길 | 2025-05-12 |
2694532 | 네트워크에 관하여... (4) | 황소자리 | 2025-05-12 |
2694503 | 프로그램 연산 후 바로 종료되는 현상 (6) | Judicious | 2025-05-11 |
2694450 | while문질문입니다. (1) | 허리품 | 2025-05-11 |
2694420 | C언어 질문할게요(유니코드,자료형,버퍼,캐스트연산자) | 은새 | 2025-05-11 |
2694370 | 내일까진데 함수호출 제발 도와주세요!!!!!!!!!11 | 들찬 | 2025-05-10 |