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);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
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 |
2654074 | 배열에 들어있는값을 포인터에 옮기고 싶어요.. | 소라 | 2024-05-07 |
2654043 | 이차원 배열에 있는 값들 더하기.. | 선아 | 2024-05-07 |
2654011 | c언어 대문자소문자, 소문자대문자 변형하기, | 샤르 | 2024-05-07 |
2653985 | 실수 자료형 표현범위있잖아요 (1) | 패틱 | 2024-05-06 |
2653957 | 뭐가틀린건가요?.. (2) | 볼1매그녀 | 2024-05-06 |
2653934 | malloc을 이용한 출력 (1) | 하예 | 2024-05-06 |
2653906 | 숫자 야구 게임인데요.. (2) | 상큼한캔디 | 2024-05-06 |
2653883 | 구조체 질문이요.. 연결리스트. (1) | 별 | 2024-05-05 |
2653802 | 배열에 저장된 데이터와 원하는 데이터비교하는것좀.. | 리카 | 2024-05-05 |