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);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
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 |
2652226 | 결과 값이 무조건0 으로 나옵니다...... (5) | 빗줄기 | 2024-04-20 |
2652198 | 연결 list 질문요~ | Sweeety | 2024-04-20 |