• 전문가 요청 쿠폰 이벤트
*석*
Bronze개인
팔로워0 팔로우
소개
등록된 소개글이 없습니다.
전문분야 등록된 전문분야가 없습니다.
판매자 정보
학교정보
입력된 정보가 없습니다.
직장정보
입력된 정보가 없습니다.
자격증
  • 입력된 정보가 없습니다.
판매지수
전체자료 2
검색어 입력폼
  • [디지털] implication chart를 이용한 등가항 소거
    ..FILE:del_eqv.cpp.hwp#include #include #include #include #include #define MAX 10 // 받아들일 상태의 최대수#define BUFFER_SIZE 30 / 한 line의 크기typedef struct state_table{ //it read state table from input fileint no; // State numberchar ps; // Present Statechar ns[2]; // Next Statechar po[3]; // Present Output}State;typedef struct imp_chart{ // making up implication chart, it is usedchar eqv[2][2]; // states inscripted in a lattice of impchar iseqv; // to make sure whether it is equiv or not}Chart;State *state[15]; // 받아들인 각 상태의 포인터int state_num; // 받아들인 상태의 수int moore_or_mealy; // line당 받아들인 입력값을 개수로 type 판단FILE *result; // result write/* init_input 함수는 main으로부터 파일 이름을 전달받아..... state[i]포인터 변수에 각 상태를연결한다 */void init_input(char *source_fname){FILE *source; // data 입력을 위한 파일int s_count = 0; // 상태 카운트char buffer[BUFFER_SIZE]; // fgets로 라인을 읽어들이기 위한 버퍼if((source = fopen(source_fname,"r")) == NULL){printf("nWrong filename! Try again.");exit(1);}--------------------------------------------------------close(source);}void print_state_num(void) // 입력받은 상태의 크기와 type를 출력{result = fopen("result.txt","w");fprintf(result,"*state_type : %s | *state_num : %dn",(moore_or_mealy == 4) ? "Moore" : "Mealy" , state_num);}void check_term(char *term){if(term[0] == term[1])term[0] = term[1] = '';}void print_imp_chart(Chart imp_chart[MAX][MAX], int step_count){ // 각 step 마다의 implication chart를 출력하기 위한 함수int row, col, line; // line -> 입력값 x=0 or 1을 위한 구분변수fprintf(result,"nn", step_count);for(row = 1; state[row] != NULL ; row++){for(line = 0 ; line ns[i]:state[row]->ns[i];low=(state[col]->ns[i]>state[row]->ns[i])?state[col]->ns[i]:state[row]->ns[i];if(i)/* (1) */ if((imp_chart[state[row]->no][state[col]->no].eqv[0][0]==high)&&(imp_chart[state[row]->no][state[col]->no].eqv[0][1]==low))high = low = '';if(high == low)high = low = '';imp_chart[state[row]->no][state[col]->no].eqv[i][0]=high;imp_chart[state[row]->no][state[col]->no].eqv[i][1]=low;/* (2) */ if((imp_chart[state[row]->no][state[col]->noqv_list, int max_num){// 등가항을 소거하는 함수int i, j;for(i = 0 ; i ns[j] = eqv_list[max_num-1];eqv_list[max_num] = ''; // 사용된 등가항은 list에서 삭제state[max_num] = NULL; // state 포인터 역시 삭제}void print_final_state_table(void){int count;fprintf(result,"nnnn < final state table >");fprintf(result,"n ---------------------");fprintf(result,"n P.S. | N.S | P.O");if(moore_or_mealy == 4)fprintf(result,"n |x=0 1 |");else fprintf(result,"n |x=0 1 |x=0 1");for(count = 0 ; state[count] != NULL ; count++){fprintf(result,"n ---------------------");fprintf(result,"n %c | %c %c | %c %c",state[count]->ps,state[count]->ns[0], state[count]->ns[1], state[count]->po[0], state[count]->po[1]);}fprintf(result,"n ---------------------");}void state_resort(void){ /* 등가항을 정리한 state[i] 포인터 배열에서 등가삭제 후 null로 처리된항을 제외하고 다시 sort */int i, j;for(j = i = 0 ; i < state_num ; i++){if(state[i] == NULL)continue;state[j] = state[i];state[j++]->no = i;}}/* 최종 implication chart에서 등가항을 찾은 후 그 등가항들을 대체될 항들은 짝수, 삭제될항들은 홀수번째로 eqv_l[s_count]->po[1]);if(moore_or_mealy == 4) state[s_count]->po[1] = '';state[s_count]->no = s_count;state[s_count]->po[2] = '';state_num++;if(moore_or_mealy < 4){printf("nThe data is neither moore nor mealy.");exit(1);}while(1){int i;if(fgets(buffer, BUFFER_SIZE,source) != NULL){state[++s_count] = (State *)malloc(sizeof(State));if(moore_or_mealy != (i = sscanf(buffer,"%c %c %c %c %c", &state[s_count]->ps, &state[s_count]->ns[0],&state[s_count]->ns[1], &state[s_count]->po[0], &state[s_count]->po[1]))){printf("n col input type mismatch! check!");exit(1);}state[s_count]->no = s_count;if(moore_or_mealy == 4) state[s_count]->po[1] = '';state[s_count]->po[2] = '';state_num++;}else{s_count = 0;break;}}while(state[s_count] != NULL){fprintf(result,"n%c %c %c %c %c", state[s_count]->ps, state[s_count]->ns[0], state[s_count]->ns[1],state[s_count]->po[0], state[s_count]->po[1]);s_count++;}fprintf(result,"n");fclose(source);}void print_state_num(void){result = fopen("result.txt","w");fpri0; state[row] != NULL ; row++)for(col = 0 ; col < row ; col++)if(imp_chart[row][col].iseqv != 'X')for(int i = 0; i < 2 ; i++)if(imp_chart[row][col].eqv[i][0] != ''){if(imp_chart[imp_chart[row][col].eqv[i][1]-'a'][imp_chart[row][col].eqv[i][0]-'a'].iseqv == 'X'){imp_chart[row][col].eqv[i][0] = '';imp_chart[row][col].eqv[i][1] = '';}if((imp_chart[row][col].eqv[0][0] == '') && (imp_chart[row][col].eqv[1][0] == '')){imp_chart[row][col].iseqv = 'X';add_not_eqv++;}}if(add_not_eqv){print_imp_chart(imp_chart, step_count);}}}void delete_eqv_state(char *eqv_list, int max_num){int i, j;for(i = 0 ; i < state_num ; i++){for(j = 0 ; j < 2 ; j++)if(state[i]->ns[j] == eqv_list[max_num])state[i]->ns[j] = eqv_list[max_num-1];}state[eqv_list[max_num]-'a'] = NULL;eqv_list[max_num] = NULL;del_state_num++;}void print_final_state_table(void){int count;fprintf(result,"nnnn < final state table >");fprintf(result,"n ---------------------");fprintf(result,"n P.S. | N.S | P.O");if(moore_or_mealy =c
    공학/기술| 2003.11.24| 7페이지| 3,000원| 조회(684)
    미리보기
  • [자료구조론] 사칙연산에서 infix의 postfix로의 변환
    ..FILE:POSTFIX.hwp#include #include #include #define MAX 100/* 스택의 최대 크기 설정 */int stack[MAX];int top;void init_stack(void){top = -1;}int push(int val){if(top >= MAX - 1){printf("n Stack overflow.");exit(1);}stack[++top] = val;return val;}/* 스택의 값을 팝 */int pop(void){if(top < 0){printf("n Stack underflow.");exit(1);}return stack[top--];}/* 스택의 값을 참조*/int get_stack_value(void){return (top < 0) ? -1 : stack[top];}/* 스택 empty 검사 */int is_stack_empty(void){return (top < 0);}/* stack에서 pop의 시점을 정하기 위한 연산자 우선순위 부여 함수 */int check_order(int oper){if(oper == '(') return 0;else if(oper == '+' || oper == '-') return 1;else if(oper == '*' || oper == '/') return 2;else return 3;}/* check_error()함수 에서 digit_count변수 카운트시 1자리수 이상의 수 입력으로인한 잘못된 카운트 입력을 막고 하나의 수로 취급하기 위해 체크하는 함수 */char *check_digit(char *in_exp){while(isdigit(*in_exp)){in_exp++;}return --in_exp;}void postfix(char *src_exp, char *dst_exp){init_stack();while(*src_exp){if(*src_exp == '('){push(*src_exp);src_exp++;}else if(*src_exp == ')'){ >= check_order(*src_exp)){*dst_exp++ = pop(); /* 연산자를 만나면 우선순위기 낮은 연산자를 */*dst_exp++ = ' '; /* 만날 때까지 pop한다. */}push(*src_exp);src_exp++;}else if(isdigit(*src_exp)){ /* 숫자는 그대로 출력 */do{*dst_exp++ = *src_exp++;}while(isdigit(*src_exp));*dst_exp++ = ' ';}elsesrc_exp++;}while(!is_stack_empty()){*dst_exp++ = pop();*dst_exp++ = ' ';}dst_exp--;*dst_exp = 0;}int calculate(char *post_exp){int val; /* 연산결과 저장 */init_stack(); /* 스택의 초기화 */while(*post_exp){if(isdigit(*post_exp)){val = 0;do{val = val*10 + *post_exp - '0';/*한자리 이상의 수 입력대비 */post_exp++;}while(isdigit(*post_exp));push(val);}else if(*post_exp == '+'){ /* 연산 순서를 생각해야하는 -, /는 */push(pop() + pop()); /* val 변수 이용 */}else if(*post_exp == '*'){push(pop() + pop());}else if(*post_exp == '-'){val = pop();push(pop() - val);}else if(*post_exp == '/'){val = pop();push(pop() / val);}else;post_exp++;}return pop();}/*잘못된 입력에 대한 에러 체크함수*/void error_check(char *in_exp){int digit_count=0, oper_count=0, left_brace_count=0, right_brace_count=0;/* 피연산자 연+' || *in_exp == '-' || *in_exp == '/' || *in_exp == '*'){oper_count++;}else if(*in_exp == ' ');else{printf("수식내 잘못된 문자 입력에 의한 오류입니다.n다시 시도하세요.n");exit(0);}}while(*(in_exp++) == '');/*중위법으로 입력된 문자열에서 각요소별로 카운트*/if(digit_count == 0){printf("수식이 입력되지 않았습니다.n다시 시도하세요.n");exit(0);}if(left_brace_count != right_brace_count){printf("괄호입력 오류입니다.n다시 시도하세요.n");exit(0);}/* '('와 ')'의 입력 개수가 같은지 검사 */if(digit_count != oper_count + 1){printf("피연산자와 연산자의 수가 맞지 않습니다.n다시 시도하세요.n");exit(0);}}void main(void){int result;/*변환된 후위법의 연산결과*/char in_exp[256];/*초기 입력받은 중위법의 수식*/char post_exp[256];/*변환된 후위법의 수식*/printf("식을 입력하세요 : ");scanf("%s",in_exp);/* 수식입력*/error_check(in_exp);/*입력 에러 체크*/postfix(in_exp, post_exp);printf("nPostfix : %s", post_exp);/*후위법으로의 변환*/result = calculate(post_exp);printf("n연산 결과 : %d", result);/*수식의 연산*/}..FILE:POSTFIX.CPP#include #include #include #define MAX 100int stack[MAX];int top;void init_stack(void){top = -1;}int push(int val){if(top >= MAX - 1){printf("n Stack oreturn (top < 0);}/* stack에서 pop의 시점을 정하기 위한 연산자 우선순위 부여 함수 */int check_order(int oper){if(oper == '(') return 0;else if(oper == '+' || oper == '-') return 1;else if(oper == '*' || oper == '/') return 2;else return 3;}/* check_error()함수 에서 digit_count변수 카운트시 1자리수 이상의 수 입력으로인한 잘못된 카운트 입력을 막고 하나의 수로 취급하기 위해 체크하는 함수 */char *check_digit(char *in_exp){while(isdigit(*in_exp)){in_exp++;}return --in_exp;}void postfix(char *src_exp, char *dst_exp){init_stack();while(*src_exp){if(*src_exp == '('){push(*src_exp);src_exp++;}else if(*src_exp == ')'){while(get_stack_value() != '('){*dst_exp++ = pop();*dst_exp++ = ' ';}pop();src_exp++;}else if(*src_exp == '+' || *src_exp == '-' || *src_exp == '/' || *src_exp == '*'){while(!is_stack_empty() && check_order(get_stack_value()) >= check_order(*src_exp)){*dst_exp++ = pop();*dst_exp++ = ' ';}push(*src_exp);src_exp++;}else if(isdigit(*src_exp)){do{*dst_exp++ = *src_exp++;}while(isdigit(*src_exp));*dst_exp++ = ' ';}elsesrc_exp++;}while(!is_stack_empty()){*dstexp));push(val);}else if(*post_exp == '+'){ /* 연산 순서를 생각해야하는 -, /는 */push(pop() + pop()); /* val 변수 이용 */}else if(*post_exp == '*'){push(pop() + pop());}else if(*post_exp == '-'){val = pop();push(pop() - val);}else if(*post_exp == '/'){val = pop();push(pop() / val);}else;post_exp++;}return pop();}/*잘못된 입력에 대한 에러 체크함수*/void error_check(char *in_exp){int digit_count=0, oper_count=0, left_brace_count=0, right_brace_count=0;/* 피연산자 연산자 '(' ')' */if(*in_exp == NULL){printf("입력된 수식이 없습니다.n다시 시도하세요.n");exit(1);}/*입력된 값이 없을 때*/do{if(*in_exp == '(')left_brace_count++;else if(*in_exp == ')'){right_brace_count++;}else if(isdigit(*in_exp)){in_exp = check_digit(in_exp);digit_count++;}else if(*in_exp == '+' || *in_exp == '-' || *in_exp == '/' || *in_exp == '*'){oper_count++;}else if(*in_exp == ' ');else{printf("수식내 잘못된 문자 입력에 의한 오류입니다.n다시 시도하세요.n");exit(0);}}while(*(in_exp++) == '');/*중위법으로 입력된 문자열에서 각요소별로 카운트*/if(digit_count == 0){printf("수식이 입력되지 않았습니다.n다시 시도하세요.n");exit(0);}if(left_brace_*/
    공학/기술| 2003.11.24| 4페이지| 1,000원| 조회(456)
    미리보기
전체보기
해캠 AI 챗봇과 대화하기
챗봇으로 간편하게 상담해보세요.
2026년 04월 03일 금요일
AI 챗봇
안녕하세요. 해피캠퍼스 AI 챗봇입니다. 무엇이 궁금하신가요?
3:53 오전
문서 초안을 생성해주는 EasyAI
안녕하세요 해피캠퍼스의 20년의 운영 노하우를 이용하여 당신만의 초안을 만들어주는 EasyAI 입니다.
저는 아래와 같이 작업을 도와드립니다.
- 주제만 입력하면 AI가 방대한 정보를 재가공하여, 최적의 목차와 내용을 자동으로 만들어 드립니다.
- 장문의 콘텐츠를 쉽고 빠르게 작성해 드립니다.
- 스토어에서 무료 이용권를 계정별로 1회 발급 받을 수 있습니다. 지금 바로 체험해 보세요!
이런 주제들을 입력해 보세요.
- 유아에게 적합한 문학작품의 기준과 특성
- 한국인의 가치관 중에서 정신적 가치관을 이루는 것들을 문화적 문법으로 정리하고, 현대한국사회에서 일어나는 사건과 사고를 비교하여 자신의 의견으로 기술하세요
- 작별인사 독후감