c언어 bool연산
바람
밑에 코드보시면 Recode구조체안의 char homework[10]을 bool로해서 有일때는 10으로 無일땐 0으로해서 총점계산후 학점출력을 해야되는데 bool로 하는 부분을 모르겠습니다.
#includestdio.h
const int TRUE=1;
const int FALSE=0;
typedef struct Recode{
char student_number[10];//학번
char name[10];//이름
int attend;//출석15%
int midterm;//중간35%
int finals;//기말40%
char homework[10];//과제
}recode;
int total_score(struct Recode c);//총점 = 출석+중간+기말+과제
void grade(int n);//학점 = 총점 = 95(A+), 90(A), 85(B+), ...., 60미만(F)
void print(struct Recode c);
void show(struct Recode ts);
int homework(struct Recode c);
int main()
{
int a,b,c,d;
recode c1={1, 김동하, 95, 88, 90, 有};
recode c2={2, 윤동욱, 90, 98, 96, 無};
recode c3={3, 이상준, 92, 75, 70, 有};
recode c4={4, 차현석, 94, 95, 90, 無};
a=total_score(c1);
b=total_score(c2);
c=total_score(c3);
d=total_score(c4);
printf(학번이름출석중간기말과제총점학점\n);
show(c1);
printf(%d,total_score(c1));
grade(a);
show(c2);
printf(%d,total_score(c2));
grade(b);
show(c3);
printf(%d,total_score(c3));
grade(c);
show(c4);
printf(%d,total_score(c4));
grade(d);
return 0;
}
int total_score(struct Recode c)
{
int temp;
temp = ((c.attend*15/100)+(c.midterm*35/100)+(c.finals*40/100)+(c.homework));
빨간 부분을 10 이나 0으로 해서 계산해야하는데
어떤식으로 계산해야될지 모르겠습니다. 有,無
return temp;
}
void grade(int n)
{
switch(n/5)
{
case 20:
printf(A+\n);
break;
case 19:
printf(A+\n);
break;
case 18:
printf(A\n);
break;
case 17:
printf(B+\n);
break;
case 16:
printf(B\n);
break;
case 15:
printf(C+\n);
break;
case 14:
printf(C\n);
break;
case 13:
printf(D+\n);
break;
case 12:
printf(D\n);
break;
default:
printf(F\n);
break;
}
}
void show(struct Recode ts)
{
printf(%s%s%d%d%d%s,ts.student_number,ts.name,ts.attend,ts.midterm,ts.finals,ts.homework);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2655491 | 키보드 인식, 랜덤 함수 or 헤더 (2) | 별 | 2024-05-20 |
2655471 | 링 버퍼 구현된 소스 인데요.. 이해가 잘안되서요.. | 소심한녀자 | 2024-05-20 |
2655440 | test파일이 안 되요. (2) | 리라 | 2024-05-19 |
2655416 | 고수님들 도움이 절실합니다. (2) | 세리 | 2024-05-19 |
2655361 | 엔터 입력받을때까지 기다리는 getchar (1) | 큰모음 | 2024-05-19 |
2655328 | 함수에서 포인터 (3) | 모아 | 2024-05-18 |
2655299 | 아이콘바꾸는법..? | 소 | 2024-05-18 |
2655271 | scanf 입력받으면 쭉 실행되는.. (5) | ComeOn | 2024-05-18 |
2655184 | 이 세개 프로그램좀 해결해주실.... 고수님들???? (3) | 말달리자 | 2024-05-17 |
2655129 | 다차원 배열 원소들 주소계산하는거 질문이요~ | 터전 | 2024-05-17 |
2655103 | AVRstudio MoveAxis. MoveLine 함수질문 | 앨버트 | 2024-05-16 |
2655072 | 콘솔창의 위치와 크기를 정하고 싶습니다. | 딥레드 | 2024-05-16 |
2655044 | 자료구조랑 online judge site에 대해서 질문있습니다... (1) | 뽀송뽀송 | 2024-05-16 |
2655016 | 별찍기 문제 중 이해안되는 부분이 있어요... | 도전중 | 2024-05-16 |
2654986 | 입력받은 성적을 배열에 저장하기 (3) | 안녕나야 | 2024-05-15 |
2654959 | ===========-이런거 미리 지정하는법 (1) | 김자영 | 2024-05-15 |
2654930 | 도와주십시요 ㅜㅜ 자료구조 ㅜㅜ | 도널드 | 2024-05-15 |
2654881 | PID 모듈 검색 부분 질문합니다 . | 이름없음 | 2024-05-14 |
2654850 | 조건에 만족하는 다음 수를 찾고 싶습니다. | 초엘 | 2024-05-14 |
2654790 | 두파일간 byte단위 txt파일 복사 中 | 슬찬 | 2024-05-14 |