기타/알아두면 좋을것들
Gist를 사용하여 Tistory에 소스코드를 올리는 방법
Holuck
2019. 5. 23. 22:14
Gist를 사용하여 Tistory에 멋있게 자신의 소스 코드를 올리는 방법을 한번 알아보겠습니다!
우선
Discover gists
GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
Gist사이트에 들어가서 로그인을 합니다. (Github아이디가 있으시다면 그 아이디로 로그인하시면 됩니다.)

로그인 하시면 오른쪽 우측상단에 +버튼이 있습니다. +버튼을 누르시면 이제 Create a new Gist를 할 수 있는 창이 나옵니다.

저는 공개하지 않기 원하기 때문에 Create secret gist를 선택하였습니다!
다음화면입니다.

<script>를 사용하여 삽입하기 때문에 표시해둔 버튼을 눌러 스크립트문을 복사합니다.
이제 블로그 글쓰기로 돌아와서

HTML 을 선택해줍니다.

이렇게 적당한 위치에 삽입 해준다음에 글쓰기 완료를 눌러주면 아래와 같이 코드가 나옵니다!
(BOJ 10828번 스택)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _CRT_SECURE_NO_WARNINGS | |
#include<iostream> | |
#include<cstdio> | |
#include<string> | |
using namespace std; | |
int command_count; | |
struct Stack{ | |
int stack_data[10001]; | |
int size; | |
Stack(){ | |
size=0; | |
} | |
void push(int n){ | |
stack_data[size]=n; | |
size++; | |
} | |
int empty(){ | |
if(size==0) return 1; | |
else return 0; | |
} | |
int pop(){ | |
if(empty()==1){ | |
//it's empty stack!! | |
return -1; | |
} | |
else{ | |
size--; | |
return stack_data[size]; | |
} | |
} | |
int stack_size(){ | |
return size; | |
} | |
int top(){ | |
if(empty()==1){ | |
//it's empty stack!! | |
return -1; | |
} | |
else{ | |
return stack_data[size-1]; | |
} | |
} | |
}; | |
int main(){ | |
//push pop size empty top | |
string command; | |
Stack s; | |
cin >> command_count; | |
for(int i=0;i<command_count;i++){ | |
cin >> command; | |
if(command=="push"){ | |
int num; | |
cin >> num; | |
s.push(num); | |
} | |
else if(command=="pop"){ | |
cout << s.pop() <<'\n'; | |
} | |
else if(command=="size"){ | |
cout << s.stack_size() << '\n'; | |
} | |
else if(command=="top"){ | |
cout << s.top() << '\n'; | |
} | |
else if(command=="empty"){ | |
cout << s.empty() << '\n'; | |
} | |
} | |
} |