C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[18762] Re:도와주세요.. 에러가 16개.. ㅠ.ㅠ 전혀 모르겠네요..
만해 [greenuri] 877 읽음    2002-05-23 03:04
안녕하세요 만해입니다.

헐헐~

넘 오래된거라서요

잘 기억이 안나는데요

우선 에러만 잡아 봤습니다.

//---------------------------------------------------------------------------
#include <stdio.h>
#include <alloc.h>
typedef struct polyNode *polyPtr;
typedef struct{
    int coef;
    int exp;
    polyPtr link;
}polyNode;
polyPtr d,a,b;
//---------------------------------------------------------------------------
polyNode* padd(polyNode* a, polyNode* b);
void attach(int coeff, int expo, polyNode *ptr);
int compare(int a , int b);
//---------------------------------------------------------------------------
int compare(int a, int b)
{
  if ( a > b )
    return 1;
  else if ( a== b )
    return 0;
  else
    return -1;
}
//---------------------------------------------------------------------------
void main()
{
  polyNode* Root;
  polyNode a,b,c;
  a.coef = 2;
  a.exp = 1;
  b.coef = 2;
  b.coef = 2;
  a.link = &b;
  b.link = &c;
  c.link = NULL;
  attach(2, 3, &c);
  Root->link = a.link ;
  Root = padd(&a,&b);

  for ( ; Root ; Root = Root->link )
    printf("%d %d",Root->coef,Root->exp);
}
//---------------------------------------------------------------------------
polyNode* padd(polyNode* a, polyNode* b)
{
    polyNode* temp;
    polyNode* temp1;
    polyNode* temp2;
    int sum;
    temp2 = (polyNode*)malloc(sizeof(polyNode));
    //if (IS_FULL(temp2)) return;
    temp1 = temp2;

    while (a && b)
    switch (compare(a->exp , b->exp))
    {
        case -1 :
                attach(b->coef, b->exp, &temp2);
                b = b->link;
                break;
        case   0 :
                sum = a->coef + b->coef;
                if(sum)
                    attach(sum, a->exp, &temp2);
                a = a->link;
                b = b->link;
                break;
        case   1 :
                  attach(a->coef, a->exp, &temp2);
                  a = a->link;
                  break;
    }
    for (;a;a = a->link) attach(a->coef, a->exp, &temp2);
    for (;b;b = b->link) attach(b->coef, b->exp, &temp2);
    temp2->link = NULL;
    temp = temp1;
    temp1 = temp1->link;
    free(temp);
    return temp1;
}
//---------------------------------------------------------------------------
void attach(int coeff, int expo, polyNode *ptr)
{
    polyNode* temp;
    temp = (polyPtr)malloc(sizeof(polyNode));
//    if (IS_FULL(temp)) return;
    temp->coef = coeff;
    temp->exp = expo;
    ptr->link = temp;
    ptr = temp;
}
//---------------------------------------------------------------------------

그런데 별 도움은 안될것 같네요 그럼 이만~

참 compare() 함수하고

IS_FULL() 함수는 아마 기존에 존재 하지 않은

프로그램 내의 정의되어 있는 사항 같네요

+ -

관련 글 리스트
18760 도와주세요.. 에러가 16개.. ㅠ.ㅠ 전혀 모르겠네요.. 언푸레 897 2002/05/23
18762     Re:도와주세요.. 에러가 16개.. ㅠ.ㅠ 전혀 모르겠네요.. 만해 877 2002/05/23
18763         Re:Re:네 감사드립니다 만해님. 언푸레 755 2002/05/23
18764             Re:Re:Re:네 감사드립니다 만해님. 만해 797 2002/05/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.