Skip to content

Instantly share code, notes, and snippets.

View jiunbae's full-sized avatar
🏠
Working from home

Jiun Bae jiunbae

🏠
Working from home
View GitHub Profile
@jiunbae
jiunbae / raw_input
Last active August 29, 2015 14:19
raw_input with Cpp
#include<stdlib.h>
char * input(void)
{
register char ch, * string = (char*)calloc(sizeof(char), sizeof(int));
for (register int count = 0; (string[count] = getchar()) != '\n' || (string[count] = 0); string = (char*)realloc(string, sizeof(char)*++count + sizeof(int)));
return string;
}
char * strmid(register char * string, register int start, register int len)
{
int string_len = strlen(string) > len ? len : strlen(string);
register char * str = (char *)calloc(sizeof(char), string_len + sizeof(int));
for (int i = start; i <= string_len; i++)
str[i - start] = string[i];
return str;
}
@jiunbae
jiunbae / xArray
Last active August 29, 2015 14:20
/*
정수를 받아들여 오름차순으로 보관하는 클래스 구현
1. pseudo code를 포함한 어떤 언어를 사용하든 상관 없음
2. 정확한 문법은 무시해도 좋고 논리만 알아볼 수 있으면 됨
3. 클래스 이름 : xArray
4. 구현해야 할 멤버 함수
bool Seek(int i) : 주어진 인자의 정수가 있는지 확인, 중복 보관 없음
bool Add(int i) : 새로운 정수를 보관, 위의 Seek 함수 이용
bool Del(int i) : 주어진 정수를 제거, 위의 Seek 함수 이용
5. 그 외 필요한 멤버 변수나 함수 등은 제한 없음
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
template<typename type>void print_vector(std::vector<type> vector)
{
for_each(vector.begin(), vector.end(), [](type n){static int temp = 0; cout << temp++ << " : " << n << endl; });
}
template <typename type> std::vector<type> fibonacci(type n)
#include<vector>
#include<stack>
#include<algorithm>
#include<iostream>
#include<functional>
using namespace std;
template <typename type> void vector_in(vector<type> * vec, int count)
{
for (int i = 0; i < count; i++)
{
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
#pragma warning (disable : 4996)
template <typename type> type _max(type a, type b)
{
return a > b ? a : b;
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef struct {
int start, end, value;
}vertex_value;
vertex_value vertex_value_in()
{
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
typedef struct{
int x, y; double tan; int index;
}POINT;
int main()
{
int vertex_max;
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
typedef struct {
int x, y;
double tan;
int index;
}POINT;
int main()
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
struct Point {
double x, y;
};
struct d_p {