Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code review: 0915 #3

Open
raipen opened this issue Mar 9, 2024 · 0 comments
Open

code review: 0915 #3

raipen opened this issue Mar 9, 2024 · 0 comments

Comments

@raipen
Copy link

raipen commented Mar 9, 2024

pb1

  1. 그냥 fa나 fb에 -1안 하고 저장하는게 더 코드 깔끔하지 않았을까 싶긴 함
    printf("A(x):");
    sa = 0;
    fa = readP(terms, input1, sa); // readP는 읽은 개수를 반환했기 때문에 배열 주소는 arr[개수 - 1]임

    for (int i = sa; i < fa; i++) printf("%d^%d + ", terms[i].coef, terms[i].expon);

    printf("B(x):");
    sb = fa;
    fb = readP(terms, input2, sb);

    for (int i = sb; i < fb; i++) printf("%d^%d + ", terms[i].coef, terms[i].expon);
    sc = fb;

    while ((sa <= fa) && (sb <= fb)) {
    ....
  1. 다른 조건들까지 bigCoef에 넣어서 처리하니까 좀 보기 안 좋음. 의미를 명확하게 할 수 있도록 추가 변수들을 써줬다면 좋을 것 같음.
//위에서 fa -1, fb -1 안 하는걸로 바꿨다고 치고 ㅇㅇ
int isAEnd = sa > fa ? 1: 0;
int isBEnd = sb > fb ? 1: 0;

if(isAEnd && isBend) break;
if(isAEnd) //C에 B만 더해주기
if(isBEnd) //C에 A만 더해주기

int bigCoef = COMPARE(terms[sa].expon, terms[sb].expon);
switch(bigCoed){
    case -1: //C에 B만 더해주기
    ....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant