[자료구조 자료구조] polynomial by linked list (링크드리스트를 이용한 다항식)
- 최초 등록일
- 2004.04.24
- 최종 저작일
- 2004.04
- 6페이지/ C언어
- 가격 2,000원
소개글
C로 쓴 자료구조론
링크드리스트로 구현한 다항식 계산 소스이구요.
2개의 다항식을 입력받아 계산해주는겁니다.
목차
없음
본문내용
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define IS_FULL(ptr) (!(ptr))
#define NULL 0
#define COMPARE(x,y) (((x) < (y)) ? -1: ((x) == (y)) ? 0: 1)
typedef struct poly_node *poly_pointer;
typedef struct poly_node{
int coef;
int expon;
poly_pointer link;
};
poly_pointer a,b,d,aptr,bptr,dptr;
void init();
poly_pointer padd(poly_pointer a, poly_pointer b);
void attach(int coefficient, int exponent, poly_pointer *ptr);
int cha(char ch);
void main()
{
char str1[100], str2[100];
int coe, exp, i, strsize;
init();
printf("Single Liked List를 이용한 다항식 덧셈 연산\n");
printf("(조건 : 지수와 계수는 0보다 커야함)\n");
printf("ex> 5x^6+4x+2\n\n");
printf("첫번째 다항식을 입력하시오 : ");
scanf("%s", &str1);
if(str1[0]=='x'){
if(str1[1]=='^'){
coe=1;
exp=cha(str1[2]);
attach(coe, exp, &a);
}
참고 자료
없음