*종*
Bronze개인
팔로워0 팔로우
소개
등록된 소개글이 없습니다.
전문분야 등록된 전문분야가 없습니다.
판매자 정보
학교정보
입력된 정보가 없습니다.
직장정보
입력된 정보가 없습니다.
자격증
  • 입력된 정보가 없습니다.
판매지수
전체자료 3
검색어 입력폼
  • [자료구조] infix -> postfix
    ## Program Overview ##1. main 함수에서 expr에 식을 입력 받는다.2. err_check 함수에서 체크한 에러의 종류- 오퍼랜드 다음에 이어서 다시 오퍼랜드가 나올 수 없다.- 오퍼랜드는 오퍼레이터 보다 하나가 더 많아야 한다.- 왼쪽 괄호와 오른쪽 괄호의 개수는 같아야 한다.3. err_check 함수에서 리턴된 값(1: 정상 , 0: 잘못된 입력) 으로 에러 체크후 postfix 호출4. postfix 함수에서 오퍼랜드는 그냥 화면에 출력.연산자는 우선순위를 비교해 push, pop 함수를 이용, 스텍에 저장,삭제 한다.5. pop함수에서 스택에서 pop 함과 동시에 화면에 item을 출력한다.## Program Source ###include#include#include#define MAX_STACK_SIZE 50#define MAX_EXPR_SIZE 50int top = 0; // top of Stacktypedef enum { lparen, rparen, plus, minus, times, divide, operand, eos} precedence;precedence stack[MAX_STACK_SIZE]; // declare Stackchar expr[MAX_EXPR_SIZE]; // input charater arraystatic int isp[] = { 0, 19, 1, 1, 2, 2, 3, 0 }; // precedence number in stackstatic int icp[] = { 20, 19, 1, 1, 2, 2, 3, 0 }; // precedence number at store// declare functionvoid postfix(void);precedence get_token(char *symbol, int *n);void push(int *top, precedence item);precedence pop(int *top);void stack_full();precedence stack_empty();voi************************//* Main function *//* ============================================================ *//* Input: noting *//* Output: nothing *//* Purpose: call postfix, err_check function *//*********************************************************************/int main(){printf("Input : ");gets(expr);if( err_check() ) postfix(); // call postfix function after error checkreturn 0;}/*********************************************************************//* Error check function *//* ============================================================ *//* Input: noting *//* Output: int - 1 : right input *//* 0 : wrong input *//* Purpose: check wrong input *//*********************************************************************/int err_check(){int lparen_num=0 , rparen_num=0 , operand_num=0 , operator_num=0;char *p = expr; // get pointer of expr arraywhile(*p) // until end of sentence{int k = *p; // get ASCII code of characterif ( k == 40 ) lparen_num++ ; // 40 is ASCII of "("else if ( k == 4 = icp , pop stack and print tokenwhile( isp[stack[top]] >= icp[token] )print_token( pop(&top) );push(&top, token);}}while( (token = pop(&top)) != eos )print_token( token );printf("n");}/*********************************************************************//* Get_token function *//* ============================================================ *//* Input: char* -> symbol *//* int* -> n *//* Output: precedence -> symbol type *//* Purpose: get token and return type *//*********************************************************************/precedence get_token(char *symbol, int *n){*symbol = expr[(*n)++]; // get pointer of expr variableswitch(*symbol) // return type{case '(' : return lparen;case ')' : return rparen;case '+' : return plus;case '-' : return minus;case '/' : return divide;case '*' : return times;case '' : return eos;default : return operand;}}/*********************************************************************//* Push function *//* =========================================//* Purpose: store item at top of stack and increase stack pointer *//*********************************************************************/void push(int *top, precedence item){if( *top >= MAX_STACK_SIZE-1 ) //if stack is full, call stack_full function{stack_full();return;}stack[++*top] = item; // add item at top of stack}/*********************************************************************//* Pop function *//* =========================================================== *//* Input: int* -> top *//* Output: precedence -> item *//* Purpose: return item at top of stack and decrease stack pointer *//*********************************************************************/precedence pop(int *top){if(*top == -1)return stack_empty();return stack[(*top)--]; // pop item at top of stack}/*********************************************************************//* Stack_full function *//* ============================================================ *//* Input: nothing *//* Output: nothing *//* Purpose:***********/void stack_full(){printf("n Stack is full! n");}/*********************************************************************//* Stack_empty function *//* ============================================================ *//* Input: notghing *//* Output: precedence -> eos *//* Purpose: alert message full of stack *//*********************************************************************/precedence stack_empty(){printf("n Stack is empty! n");return eos;}/*********************************************************************//* Print token function *//* =========================================================== *//* Input: precedence -> k *//* Output: nothing *//* Purpose: print token of item at top of stack when pop *//*********************************************************************/void print_token(precedence k){switch(k) // print token type of k{case lparen : printf("("); break;case rparen : printf(")"); break;case plus : printf("+"); break;case minus : printf("-"); break;case ;}}
    공학/기술| 2003.04.07| 7페이지| 1,000원| 조회(691)
    미리보기
  • [자료구조] maze(미로찾기 프로그램) 평가B괜찮아요
    ▲ Program Overview. 미로찾기 프로그램을 구현해 봤습니다. 과제의 특성상 stack 의 사용법을 익힐수 있었으며 push 와 pop 의 연산을 이해할수 있게 되었습니다. 전체적인 프로그램 내용은주어진 미로 배열을 입력으로 받아 각 부분을 판단해 가며 길을 찾아나가는 방법으로구현하게 되었습니다. 또한 프로그램 구현에 있어서는 동서남북 네군데의 방향을 나타내는 함수로부터 방향을 check 할수 있게되었으며, 출발지점을 지정해 놓은 상태에서start 하도록 하였습니다. 여기서 각 방향을 check 후 이동토록 구현하였습니다.또한 각 방향을 stack을 통하여 push 와 pop 연산을 통해 이동하도록 구현되었습니다.이번 프로그램에 있어서는 stack 의 push와 pop 연산보다는 path() 부분인 방향을찾아가도록 하는 부분이 좀 시간이 걸리며 더 오래걸리었는데 이는 방향전환에 대한정확한 알고리즘을 알면서도 구현하는데 서툴렀다는 판단이 들었습니다.전체적인 프로그램은 path()를 통해서 이루어지며 이데따른 시행착오가 많았던 것같습니다. 이번 프로그램을 계기로 다음부터는 이부분에 있어서 더욱 정확한 coding능력이 필요하다는 생각이 들었습니다.Algorithm.Source Code/********************************************************************//* File Name : *//* Date : *//* Compiler : *//* Os : *//* Author : *//* Student ID : *//* ----------------------------------------------------------- *//* Description : Searching the maze *//* Etc.. : Data Structure Homework #1 (maze game) *//********************************************************************/#include #define MAX_STACK_SIZE 200#define EXIT_ROW 10#define EXIT_COL 10#define FALSE 0#define TRUE 1typedef struct{int row, col, dir;} element;element stack[MAX_STACK_SIZE]; // position;typedef struct{int vert, horiz;} offsets;offsets move[4];char maze[12][12] = { // input maze array{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1},{1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1},{1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1},{1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1},{1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1},{1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1},{1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1},{1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1},{1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1},{1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1},{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};char mark[12][12]; // mark arrayvoid path();void push(int *top, element position);element pop(int *top);/*********************************************************************//* main function *//* =========================================================== *//* Input: array *//* Output: array *//* Purpose: direction check *//********************************************************************/int main(void){int i;for (i=0; i
    공학/기술| 2003.04.07| 6페이지| 1,000원| 조회(2,535)
    미리보기
  • [자료구조] infix,postfix,연산까지.. 평가A+최고예요
    ▲ Program Overview. infix형 수식을 입력 받아 이를 postfix형으로 고치고 이를 연산하여 결과를 출력하는 프로그램을 작성 하였습니다. infix형 수식은 한자리의 자연수로 구성되며+,-,*,/의 네가지 연산과 '(','')에 의한 우선순위 연산까지 적용됩니다.프로그램에서 제한사항을 두어 error / minus 처리 루틴을 두었으며, 이에따른 연산결과의 정확한값 출력을 위해 많은 시행착오를 거치게 되었습니다.Algorithm.Source Code/************************************************************************//* File Name : *//* Date : *//* Compiler : *//* Os : *//* Author : *//* Student ID : *//* -------------------------------------------------------------- *//* Description : infix, postfinx and operation porgram *//* Etc.. : Data Structure Homework #2 (Operation) *//***********************************************************************/#include#include#define MAX_STACK 50#define MAX_SIZE 50typedef enum {lparen, rparen, plus, minus, times, divide, operand, eos} token;float compute_stack[MAX_STACK];char postorder[MAX_SIZE];token stack[MAX_STACK];token delete(int *);float compute_delete(int *);int error_check(char inorder[MAX_SIZE]);token get_token(char *, c"Result is : ");printf("%.1fn",compute());return 0;}/***********************************************************************//* error_check function *//*===============================================================*//* Input : Infix notation *//* Purpose : error_check *//**********************************************************************/int error_check(char inorder[MAX_SIZE]){int i, j, error = 0;for(i=0; inorder[i] != ''; i++){if(inorder[i] == '*' || inorder[i] == '/' || inorder[i] == '+'){if(next_operator(i,inorder)) { // 곱하기 나누기 플러스 연산자가 중복나올때 에러리턴error = 1;}}else if(inorder[i] == '('){error=1;for(j = i; inorder[j] !='';j++ ){if(inorder[j] == ')') // 왼괄호가 나왔을때 )가 나오면 no에러error = 0;}}else if(inorder[i] == ')'){ // )가 나오고 (가 나오면 no에러error=1;for(j = i; j >= 0;j-- ){if(inorder[j] == '(')error = 0;}}}if(inorder[0] == '*' || inorder[0] == '/' || inorder[0] == '+' || inorder[0] == ')' ) // 첫번째 값으로 올수 없는 것들.{error =1; }--i;if(inorder[i] == '*' || inorder[i] == '/' || inorder[i] ==n = 0;char ch;token tt;int i,index = 0;stack[0] = eos;tt = get_token(inorder, &ch, &n);for(tt ; tt != eos; tt = get_token(inorder, &ch, &n)) {if(tt == lparen) { // (괄호이면 무조건 스택배열에 addadd(&top, tt);}else if( tt == rparen) { // )괄호이면 postorder배열에 (괄호만날때까지 팝해서 저장한다.while( stack[top] != lparen )postorder[index++] = print_token(delete(&top));delete(&top);}else if( tt == operand ){if(mc){ // 음수가 셋 되어 있는 상태라면postorder[index++] = ch; // 심볼을 넣고postorder[index++] = ')'; //괄호를 닿고 mc는 0으로 한다.mc = 0;}elsepostorder[index++] = ch; // 음수 셋이 안돼어 있으면 그냥 십볼만 삽입}else if(tt == minus){if(minus_check(cnt,inorder)){ // 음수이면 (넣고 - 삽입postorder[index++] = '(';postorder[index++] = '-';mc = 1;}else{ // 음수연산자이면 그냥 삽입while(isp[stack[top]] >= icp[tt])postorder[index++] = print_token(delete(&top));add(&top, tt);}} // 그외연산자이면 우선순위대로 푸쉬 팝else if(tt == plus || tt == divide || tt == times){while(isp[stack[top]] >= icp[tt])postorder[index++] = print_token(delete(&top));add(&top, tt);}else{printf("Errorn");}cnt++;}while((t==================================================*//* Purpose : Operation store array *//***********************************************************************/token get_token(char *order, char *symbol, int *n){*symbol = order[(*n)++];switch(*symbol){case '+' : return plus;case '-' : return minus;case '/' : return divide;case '*' : return times;case '(' : return lparen;case ')' : return rparen;case '' : return eos;default : return operand;}}/*******************************************************************//* print_token() *//*===========================================================*//* Input : token *//* Output : string *//*******************************************************************/char print_token(token s){switch(s){case plus : return '+'; break;case minus : return '-'; break;case divide : return '/'; break;case times : return '*'; break;case lparen : return '('; break;case rparen : return ')'; break;case eos : printf("n string end n");}}/**************************================================================================*//* Input : Operand *//* Output : float result *//***********************************************************************/float compute() // 실수값으로 계산리턴{float num, temp, com_a, com_b;int n = 0;token tt;char symbol_c, asc_ch, k;asc_ch = '0';tt = get_token(postorder, &symbol_c, &n);for(tt ; tt != eos; tt = get_token(postorder, &symbol_c, &n)){if(tt == lparen){while( tt != rparen ){tt = get_token(postorder, &symbol_c, &n);if(tt == operand){num = symbol_c - asc_ch;temp = symbol_c-(asc_ch+(num+num));compute_add(&top, temp);} // if end} // while end} //if endelse if(tt == operand){temp = symbol_c-asc_ch;compute_add(&top, temp);}else {com_b = compute_delete(&top);com_a = compute_delete(&top);if(tt==plus)compute_add(&top, (com_a+com_b));else if(tt== minus)compute_add(&top, (com_a-com_b));else if(tt== times)compute_add(&top, (com_a*com_b));else if(tt == divide)compute_add(&top, (com_a/com_b));} // else end} // for endreturn compute습
    공학/기술| 2003.04.07| 10페이지| 1,000원| 조회(1,123)
    미리보기
전체보기
받은후기 2
2개 리뷰 평점
  • A+최고예요
    1
  • A좋아요
    0
  • B괜찮아요
    1
  • C아쉬워요
    0
  • D별로예요
    0
전체보기
해캠 AI 챗봇과 대화하기
챗봇으로 간편하게 상담해보세요.
2026년 04월 27일 월요일
AI 챗봇
안녕하세요. 해피캠퍼스 AI 챗봇입니다. 무엇이 궁금하신가요?
12:51 오후
문서 초안을 생성해주는 EasyAI
안녕하세요 해피캠퍼스의 20년의 운영 노하우를 이용하여 당신만의 초안을 만들어주는 EasyAI 입니다.
저는 아래와 같이 작업을 도와드립니다.
- 주제만 입력하면 AI가 방대한 정보를 재가공하여, 최적의 목차와 내용을 자동으로 만들어 드립니다.
- 장문의 콘텐츠를 쉽고 빠르게 작성해 드립니다.
- 스토어에서 무료 이용권를 계정별로 1회 발급 받을 수 있습니다. 지금 바로 체험해 보세요!
이런 주제들을 입력해 보세요.
- 유아에게 적합한 문학작품의 기준과 특성
- 한국인의 가치관 중에서 정신적 가치관을 이루는 것들을 문화적 문법으로 정리하고, 현대한국사회에서 일어나는 사건과 사고를 비교하여 자신의 의견으로 기술하세요
- 작별인사 독후감