export LANGUAGE=ko_KR.UTF-8
export LANG=ko_KR.UTF-8
locale-gen ko_KR ko_KR.UTF-8
update-locale LANG=ko_KR.UTF-8
dpkg-reconfigure locales
윈도우 docker-toolbox는 이래도 답이없다 (한글 키보드 입력불가, 한글출력시 nil에러)
포기해라
export LANGUAGE=ko_KR.UTF-8
export LANG=ko_KR.UTF-8
locale-gen ko_KR ko_KR.UTF-8
update-locale LANG=ko_KR.UTF-8
dpkg-reconfigure locales
윈도우 docker-toolbox는 이래도 답이없다 (한글 키보드 입력불가, 한글출력시 nil에러)
포기해라
1. utf8 형식으로 코딩됨 알림
코드시작부분에 추가
#-*- coding: utf-8 -*-
2. 유니코드 스트링
string 앞에 u를 입력
u'가나다라'
3. utf8 파일
import codecs
codecs.open('filename','읽기쓰기',encoding='utf8')
| jupyter notebook 비밀번호 변경 (0) | 2021.09.28 |
|---|---|
| python 오브젝트 함수,변수 리스트 (0) | 2018.04.02 |
| 디렉토리 순회 (0) | 2018.03.09 |
| dictionary sort (0) | 2018.02.19 |
| python string to dict or list etc... (0) | 2016.12.29 |
스트링으로 저장된 dictionary나 list 들을 바꾸는방법
import ast
a = "{ 'a':1, ... }"
d = ast.literal_eval(a)
b="['a','b']"
d = ast.literal_eval(b)
| jupyter notebook 비밀번호 변경 (0) | 2021.09.28 |
|---|---|
| python 오브젝트 함수,변수 리스트 (0) | 2018.04.02 |
| 디렉토리 순회 (0) | 2018.03.09 |
| dictionary sort (0) | 2018.02.19 |
| python2 utf8인코딩 (0) | 2017.07.29 |
#include <stdio.h>
#include <stdlib.h>
struct node
{
int end;
int w;
struct node* next;
};
struct node** adjlist;
int node_cnt=5;
struct node* adjlist2[5];
struct node* newnode(int e)
{
struct node* temp= (struct node*) malloc(sizeof(struct node));
temp->end=e;
temp->next=NULL;
temp->w=1;
return temp;
}
void insert(int s,int e)
{
if (adjlist[s] == NULL)
{
adjlist[s] = newnode(e);
}
else
{
struct node* temp = adjlist[s];
while(temp->next != NULL)
{
temp=temp->next;
}
temp->next= newnode(e);
}
}
void print()
{
int i;
struct node* temp;
for (i=0;i<node_cnt;i++)
{
temp = adjlist[i];
printf ("%d : ",i);
while ( temp!=NULL )
{
printf ("%d ",temp->end);
temp=temp->next;
}
printf ("\n");
}
}
int main(void)
{
int i;
adjlist = (struct node**)malloc(sizeof(struct node*) * node_cnt );
for (i=0;i<node_cnt; i++)
{
adjlist[i] = NULL;
}
insert(0,1);
insert(1,0);
insert(0,2);
insert(2,0);
insert(1,2);
insert(2,1);
insert(3,1);
insert(1,3);
insert(4,3);
insert(3,4);
print();
}
| hash simple linear (0) | 2015.05.22 |
|---|---|
| binary search tree ( insert, kth smallest, inorder, delete by key) (0) | 2015.05.15 |
| link list(single) (0) | 2015.05.01 |
| boolean combination (0) | 2015.05.01 |
#include <stdio.h>
#include <stdlib.h>
#define HASH_SIZE 10
int hash[HASH_SIZE];
int hf(int key)
{
return key%10;
}
void hashin(int k)
{
int f = hf(k);
int i;
if (hash[f] == -1)
{
hash[f] = k;
}
else
{
for (i= (f+1) % HASH_SIZE ; i != f ; i = (i+1) % HASH_SIZE )
{
if (hash[i] == -1)
break;
}
if (i ==f)
{// hash full
printf ("꽉참\n");
return;
}
else
hash[i] = k;
}
}
void search(int k)
{
int f = hf(k);
int i;
if (hash[f] == k)
{
printf ("있음\n");
}
else
{
for (i= (f+1) % HASH_SIZE ; i != f && hash[i] != -1 ; i = (i+1) % HASH_SIZE )
{
if (hash[i] == k)
break;
}
if (i ==f || hash[i] == -1)
{// hash full
printf ("없음\n");
return;
}
else
printf ("있음\n");
}
}
int main(void)
{
int a;
int i;
for (i=0;i<HASH_SIZE;i++)
{
hash[i] = -1;
}
hashin(55);
hashin(16);
hashin(45);
hashin(33);
hashin(78);
hashin(88);
hashin(98);
search(33);
search(45);
search(1);
return 0;
}
| simple adjacency list (0) | 2015.05.22 |
|---|---|
| binary search tree ( insert, kth smallest, inorder, delete by key) (0) | 2015.05.15 |
| link list(single) (0) | 2015.05.01 |
| boolean combination (0) | 2015.05.01 |
#include <stdio.h>
#include <stdlib.h>
struct node
{
int key;
int k;
struct node* left;
struct node* right;
};
typedef struct node* TREE;
TREE makenode(int key);
TREE insert(TREE root, int key);
void insert2(TREE root, int key);
TREE deletenode(TREE root);
TREE deletekey(TREE root, int key);
TREE insertrightmost(TREE a, TREE b);
void inorder(TREE root);
void printk(TREE root,int k);//kth smallest
int main(void)
{
TREE root=NULL;
int i;
root = insert(root, 4);
root = insert(root, 2);
root = insert(root, 1);
root = insert(root, 3);
insert2(root,6);
insert2(root,5);
insert2(root,7);
inorder(root);
printf("\n");
//printk(root,1);
//printk(root,2);
for (i=0;i<7;i++)
printk(root,i+1);
//root = deletekey(root,4);
root = deletekey(root,7);
inorder(root);
}
TREE makenode(int key)
{
TREE temp = (TREE)malloc(sizeof(struct node));
temp->key=key;
temp->left=NULL;
temp->right=NULL;
temp->k= 1;
return temp;
}
TREE insert(TREE root, int key)
{
if (root == NULL){
return makenode(key);
}
if (root->key > key)
{
root->k++;
root -> left = insert(root->left,key);
}
else if (root->key < key)
{
root->right = insert(root->right,key);
}
return root;
}
void insert2(TREE root, int key)
{
if (root == NULL){
root = makenode(key);
return;
}
if (root->key > key){
if (root->left == NULL){
root->k++;
root->left = makenode(key);
return;
}
root->k++;
insert(root->left,key);
}
else if (root->key < key){
if (root->right == NULL){
root->right= makenode(key);
return;
}
insert(root->right,key);
}
}
TREE insertrightmost(TREE a, TREE b)
{
if (a == NULL)
return b;
a->right = insertrightmost(a->right,b);
return a;
}
TREE deletenode(TREE root)
{
TREE temp, lefttemp;
temp=root->right;
//temp->left = root->left;
if (root->right && root->right->left)
{
root->left = insertrightmost(root->left,root->right->left);
}
if (root->left)
temp->left = root->left;
if (temp && temp->right)
temp->right->left=NULL;
root = temp;
return root;
}
TREE deletekey(TREE root, int key)
{
if (root==NULL)
return NULL;
if (root->key == key)
{
root= deletenode(root);
}
else if (root->key > key)
{
root ->left = deletekey(root->left,key);
}
else //if (root -> key < key)
{
root ->right = deletekey(root->right,key);
}
return root;
}
void printk(TREE root,int k)
{
if (root->k == k)
{
printf ("%d\n",root->key);
}
else if (k > root->k)
{
printk(root->right, k - (root->k));
}
else
{
printk(root->left,k);
}
}
void inorder(TREE root)
{
if (root == NULL)
return;
inorder(root->left);
printf ("%d ",root->key);
inorder(root->right);
}
| simple adjacency list (0) | 2015.05.22 |
|---|---|
| hash simple linear (0) | 2015.05.22 |
| link list(single) (0) | 2015.05.01 |
| boolean combination (0) | 2015.05.01 |
#include <stdio.h>
#include <stdlib.h>
struct _node{
int item;
struct _node* next;
};
typedef struct _node* NODE;
NODE createnode(int item);
void insert(NODE* list,NODE* tail, int item, NODE option(NODE* list, NODE* tail, NODE node) );
NODE insert_first (NODE* list, NODE* tail, NODE node);
NODE insert_last (NODE* list, NODE* tail, NODE node);
NODE insert_asc (NODE* list, NODE* tail, NODE node);
NODE insert_desc (NODE* list, NODE* tail, NODE node);
NODE insert_ith (NODE* list, NODE* tail, NODE node);
void delete_first(NODE* list,NODE* tail);
void delete_last(NODE* list, NODE* tail);
void delete_ith(NODE* list, NODE* tail);
void print_list(NODE list);
int main(void)
{
struct _node* list=NULL;
struct _node* tail=NULL;
int n,i,item;
FILE *fin=fopen("input.txt","r");
fscanf(fin,"%d",&n);
for (i=0;i<n;i++)
{
fscanf (fin,"%d",&item);
insert(&list, &tail, item, insert_desc);
}
print_list(list);
delete_first(&list,&tail);
delete_first(&list,&tail);
delete_first(&list,&tail);
delete_first(&list,&tail);
//delete_first(&list,&tail);
print_list(list);
fclose(fin);
return 0;
}
// 리스트 출력
void print_list(NODE list)
{
NODE temp=list;
while(temp!=NULL){
printf ("%d",temp->item);
temp=temp->next;}
printf ("\n");
}
// 노드만들기
NODE createnode(int item)
{
NODE temp=(NODE)malloc(sizeof(NODE*));
temp->item=item;
temp->next=NULL;
return temp;
}
// 노드추가
void insert(NODE* list,NODE* tail, int item, NODE option(NODE* list, NODE* tail, NODE node) )
{
NODE new_node=NULL;
new_node=createnode(item);
option(list,tail,new_node);
}
// 앞에
NODE insert_first(NODE* list, NODE* tail, NODE node)
{
node->next = *list;
*list=node;
return *list;
}
// 뒤에
NODE insert_last(NODE* list, NODE* tail, NODE node)
{
if ( (*list) == NULL)
{
*list=node;
*tail=node;
return *list;
}
(*tail)->next=node;
(*tail) = node;
return *list;
}
// i번째에
NODE insert_ith(NODE* list, NODE* tail, NODE node)
{
int i;
NODE prev= NULL;
NODE temp = (*list);
scanf ("%d",&i);
if ( (*list) == NULL)
{
*list=node;
*tail=node;
return *list;
}
while(temp != NULL)
{
i--;
if (i<0)
{
node->next = temp;
if (prev)
prev->next=node;
if (temp == *list)
*list=node;
//node->next = temp->next;
//temp->next = node;
break;
}
prev=temp;
temp=temp->next;
}
if (i>=0)
{
(*tail)->next=node;
(*tail) = node;
}
return *list;
}
// 오름차순
NODE insert_asc(NODE* list, NODE* tail, NODE node)
{
NODE temp=*list;
NODE prev=NULL;
if (temp == NULL)
{
*list=node;
*tail=node;
return *list;
}
while(temp !=NULL)
{
if (temp->item > node->item)
break;
prev = temp;
temp = temp->next;
}
if (temp != NULL)
node->next=temp;
if (prev != NULL)
prev->next=node;
//head, tail의 변경
if (temp == (*list))
*list = node;
if (prev == (*tail))
*tail = node;
return *list;
}
// 내림차순
NODE insert_desc(NODE* list, NODE* tail, NODE node)
{
NODE temp=*list;
NODE prev=NULL;
if (temp == NULL)
{
*list=node;
*tail=node;
return *list;
}
while(temp !=NULL)
{
if (temp->item < node->item)
break;
prev = temp;
temp = temp->next;
}
if (temp != NULL)
node->next=temp;
if (prev != NULL)
prev->next=node;
//head, tail의 변경
if (temp == (*list))
*list = node;
if (prev == (*tail))
*tail = node;
return *list;
}
void delete_first(NODE* list,NODE* tail)
{
NODE temp=*list;
*list=(*list)->next;
if (temp == *tail)
tail=NULL;
}
void delete_last(NODE* list, NODE* tail)
{
}
void delete_ith(NODE* list, NODE* tail)
{
NODE cur=*list;
NODE prev=NULL;
int i;
scanf ("%d",&i);
while(cur !=NULL)
{
if (i<=0)
{
if (prev == NULL)
{
(*list) = (*list)->next;
}
else
{
prev->next=cur->next;
}
if (cur == (*tail))
*tail=NULL;
break;
}
i--;
prev=cur;
cur=cur->next;
}
}
| simple adjacency list (0) | 2015.05.22 |
|---|---|
| hash simple linear (0) | 2015.05.22 |
| binary search tree ( insert, kth smallest, inorder, delete by key) (0) | 2015.05.15 |
| boolean combination (0) | 2015.05.01 |
n 길이의
boolean combination 출력
#include <stdio.h>
void printboolean(int a[],int index, int n)
{
int i;
if (index == n)
{
for (i=0;i<n;i++){
if (a[i] == 1)
printf ("true ");
else
printf("false ");
}
printf ("\n");
return;
}
a[index]=1;
printboolean(a,index+1,n);
a[index]=0;
printboolean(a,index+1,n);
}
int main(void)
{
int n;
int arr[1000]={0,};
scanf("%d",&n);
printboolean(arr,0,n);
}
| simple adjacency list (0) | 2015.05.22 |
|---|---|
| hash simple linear (0) | 2015.05.22 |
| binary search tree ( insert, kth smallest, inorder, delete by key) (0) | 2015.05.15 |
| link list(single) (0) | 2015.05.01 |
<input>
m n
a
b
54 98
bnbaqclwzrfkbskuwydbufxlagfgzmfwysjigulxraxrbxwnazupop
bsxicfbinhukhpunbcqnabqwbrnndwdgiwiskjbumjbwllcdddlleszybrrcntaecwtgcedpnapadfasxfnayogugndwyksije
<output>
22
bnbaqwrkbuwydfxaggwys
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define left 1
#define up 2
#define dagak 3
char a[1000];
char b[1000];
int c[100][100];
int dir[100][100];
int n,m;
void printlcs(int dir[100][100], char* a, int i,int j)
{
if (i==0 || j==0)
return;
if (dir[i][j] == dagak)
{
printlcs(dir,a,i-1,j-1);
printf ("%c",a[i]);
}
else if (dir[i][j] == up)
{
printlcs(dir,a,i-1,j);
}
else if (dir[i][j] == left)
{
printlcs(dir,a,i,j-1);
}
}
int main(void)
{
int i,j;
int logn;
// n
// nxn matrix
FILE* f = fopen ("input2.txt","r");
fscanf (f,"%d %d\n",&m,&n);
fgets(a+1,sizeof(a),f);
fgets(b+1,sizeof(b),f);
for (i=0;i<m;i++){
c[i][0] = 0;}
for (i=0;i<n;i++){
c[0][i] = 0;}
for (i=1;i<=m;i++)
{
for (j=1;j<=n;j++)
{
if (a[i] == b[j])
{
c[i][j] = c[i-1][j-1] + 1;
dir[i][j] = dagak;
}
else if (c[i-1][j] >= c[i][j-1])
{
c[i][j] = c[i-1][j];
dir[i][j] = up;
}
else
{
c[i][j] = c[i][j-1];
dir[i][j] = left;
}
}
}
printf ("%d\n",c[m][n]);
printlcs(dir,a,m,n);
printf ("\n");
}
| Parallel Sorting (0) | 2014.12.03 |
|---|---|
| bin packing2 (0) | 2014.11.26 |
| bin packing (first fit) winner tree (0) | 2014.11.19 |
| 가장 높은탑 쌓기 (0) | 2014.11.12 |
| topological sort + bellman (0) | 2014.11.12 |