성적처리프로그램 질문합니다 :-) !!
움찬
선택정렬과 이진탐색을 이용해서 푸는 문제인데.. 여기까지 하고 작성했는데
그다음부터 어떻게 하죠ㅠㅠ
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];
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2653142 | 질문드립니다.. 부탁드립니다.. | 머슴밥 | 2024-04-29 |
2653119 | cmd창[도스창, 콘솔창]에 한글이 출력이 안되요. (2) | By은지 | 2024-04-28 |
2653096 | C언어와 C++, 베이직C++의 차이 (1) | 두동 | 2024-04-28 |
2653014 | 전기 분야에서는 C언어가 어떤, 어느 용도로 쓰이나요? (7) | 처녀자리 | 2024-04-27 |
2652986 | c언어 프로그램~~ (5) | 가장 | 2024-04-27 |
2652907 | mciSendString 함수 플레이 시간, (1) | 해나 | 2024-04-26 |
2652880 | 배열입력을 묻고 싶습니다 (3) | 사에 | 2024-04-26 |
2652852 | strcmp함수 사용 관련,동적영역메모리접근관련 질문..이요. (1) | 민서 | 2024-04-26 |
2652801 | 안좋은 코딩 습관 지적좀요. | Addictive | 2024-04-25 |
2652779 | 문자열의 주소값 출력에 대해서 질문드립니다. | 핑크펄 | 2024-04-25 |
2652748 | 좀 도와주세요 ㅠ | 연체리 | 2024-04-25 |
2652719 | 다음프로그램의 실행결과를 알아보자.. (6) | 분홍이 | 2024-04-25 |
2652641 | 소인수프로그램 오류 (1) | 모람 | 2024-04-24 |
2652555 | 다이아 몬드 설명좀 부탁드립니다 | 갈기슭 | 2024-04-23 |
2652529 | 반복문을 .... (1) | 우시 | 2024-04-23 |
2652417 | 방향키로 커서이동 | 목소리 | 2024-04-22 |
2652339 | 구조체끼리 연결 왜 안될까요? (1) | 도담 | 2024-04-21 |
2652315 | 제발 도와주세요(실행파일까지첨부) | 은소라 | 2024-04-21 |
2652285 | 면산적님 질문요 (1) | 세찬 | 2024-04-21 |
2652253 | 다중루프를 이용한 이등변 삼각형 만들기 질문이요. | 알프레드 | 2024-04-20 |