회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
1
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
다른 반례들 예제 다 맞게나오는데 왜틀리는지 모르겟어요..
11656번 - 접미사 배열
mh1kim
3년 전
0
왜 틀린지 모르겟어요.. 도와주..세..여..
#include <stdio.h> #include <stdbool.h> #include <string.h> #include <stdlib.h> #define EMPTY -1 typedef struct stack{ char s[100001]; int top; }stack; void reset(stack *stk){ stk->top=EMPTY; } void push(char c,stack *stk){ stk->top++; stk->s[stk->top]=c; } char pop(stack *stk){ return (stk->s[stk->top--]); } char top(const stack *stk){ return (stk->s[stk->top]); } bool empty(const stack *stk) { return (stk->top==EMPTY); } bool full(const stack *stk) { return(stk->top==99); } int main(){ stack s; reset(&s); char str[10001]; scanf("%s",str); int l=strlen(str); char *word[l]; for(int i=l-1;i>=0;i--) push(str[i],&s); int size=s.top; for(int i=0;i<l;i++){//값넣기 word[i]=(char*)calloc(size+1,sizeof(char)); for(int k=0;k<size+1;k++) word[i][k]=pop(&s); size--; s.top=size; } char *temp; for(int i=0;i<l;i++){//정렬 for(int k=l-1;k>i;k--){ if(strcmp(word[k-1],word[k])>0){ temp=word[k-1]; word[k-1]=word[k]; word[k]=temp; } } } for(int i=0;i<l;i++) printf("%s\n",word[i]); return 0; }
댓글을 작성하려면
로그인
해야 합니다.
mh1kim 3년 전
왜 틀린지 모르겟어요.. 도와주..세..여..