소스 해석좀요 ...
지우개
질문 제목 : 소스 해석좀요
#include stdio.h
#define max(a,b) ((ab)?a:b)
#define max_degree 50
typedef struct{
int degree;
float coef[max_degree];
} polynomial;
polynomial addpoly(polynomial a, polynomial b)
{
polynomial c;
int a_index=0, b_index=0, c_index=0;
int a_degree=a.degree, b_degree=b.degree;
c.degree=max(a.degree, b.degree);
while(a_index=a.degree && b_index=b.degree){
if(a_degree b_degree){
c.coef[c_index++] = a.coef[a_index++];
a_degree--;
}
else if(a_degree == b_degree){
c.coef[c_index++] = a.coef[a_index++]+b.coef[b_index++];
a_degree--;
b_degree--;
}
else{
c.coef[c_index++] = b.coef[b_index++];
b_degree--;
}
}
return c;
}
void printpoly(polynomial p)
{
int i, degree;
degree=p.degree;
for(i=0; i=p.degree; i++)
printf(%3.0fx^%d, p.coef[i], degree--);
printf(\n);
}
void main()
{
polynomial a={3, {4,3,5,0}};
polynomial b={4, {3,1,0,2,1}};
polynomial c;
c= addpoly(a,b);
printf(\n a(x)=); printpoly(a);
printf(\n b(x)=); printpoly(b);
printf(\n c(x)=); printpoly(c);
getchar();
}
질문 내용 :
왠만한거 이해가 가는데요 진한부분이 잘 이해가 안가서요 ...
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2693956 | PlaySound재생이 안됩니다!(C에 음악넣기) | 지존 | 2025-05-06 |
2693928 | &와 *의 사용에 관한 명확한 이해 | 제나 | 2025-05-06 |
2693903 | 반복문 설명좀요 ㅠㅠ (2) | 란새 | 2025-05-06 |
2693869 | stdio.h 는 왜 쓰는건가요? (1) | 큰꽃들 | 2025-05-06 |
2693842 | 포인터 변수의 주소값끼리 더하는 것에 대해서 질문드립니다. (1) | 진솔 | 2025-05-05 |
2693811 | 소수 출력;;;; | 화이트캣 | 2025-05-05 |
2693788 | 이런 함수는 없나요? (3) | 앤드류 | 2025-05-05 |
2693758 | txt파일 불러와서 행렬로 저장 | 큰애 | 2025-05-05 |
2693727 | scanf 오류 문제!! (2) | 큰나래 | 2025-05-04 |
2693704 | 구조체 주소록 문제인데 도와주세요 (2) | 도1도캣 | 2025-05-04 |
2693676 | 열혈강의 c언어 질문입니다 | 하양이 | 2025-05-04 |
2693647 | 12.620000 을요 12.620 으로 어떻게 표현해요? (2) | 파도 | 2025-05-04 |
2693619 | 타이틀 코드.. | 단순드립 | 2025-05-03 |
2693591 | 컴파일 에러에서 질문드립니다 (3) | 게자리 | 2025-05-03 |
2693463 | 동적할당 이용시 fwrite사용을 어떻게 해야하나요..? (10) | 일본어못해요 | 2025-05-02 |
2693387 | 배열문제입니다 수정오류캡쳐했습니다 (6) | 연하얀 | 2025-05-01 |
2693356 | text 입출력 내림차순 질문입니다 ㅠ | 빛글 | 2025-05-01 |
2693328 | C언어를이용해서 .txt파일 외에 다른 확장자 파일 삭제가 가능한지.. (2) | 대나무 | 2025-05-01 |
2693299 | 파일입출력 바이너리파일 | 독특한 | 2025-04-30 |
2693273 | 오류 (1) | 귀1여운렩 | 2025-04-30 |