본문 바로가기

C언어

[C언어] 별표로 달팽이 그리기 #include void main() { int a = 0, b = 0, c = 0; int in; int n = 1; int array[30][30] = { 0, }; printf("���� ���� : "); scanf_s("%d", &in); for (; n b; b++, n++) { array[a][b] = n; } for (a = c + 1, b = in - 1 - c; in - c>a; a++, n++) { array[a][b] = n; } for (a = in - 1 - c, b = in - 2 - c; c c; a--, n++) { array[a][b] = n; } } for (a = 0; a < in; a++) { for (b = 0; b < in; b++) { printf("%3d", ..
[C언어] 백준 1991번 트리 순회 *이 포스트에서 문제의 답안은 C언어로 구성했습니다. #include #include typedef char BTData; typedef struct _bTreeNode { BTData data; struct _bTreeNode * left; struct _bTreeNode * right; } BTreeNode; BTreeNode * MakeBTreeNode(BTData data) { BTreeNode * nd = (BTreeNode*)malloc(sizeof(BTreeNode)); nd->data = data; nd->left = NULL; nd->right = NULL; return nd; } BTreeNode * SearchTree(BTreeNode * bt, BTData data) { if (bt..
[C언어] 백준 1158번 조세퍼스 문제 *이 포스트에서 문제의 답안은 C언어로 구성했습니다. #include #include #ifndef __C_LINKED_LIST_H__ #define __C_LINKED_LIST_H__ #define TRUE1 #define FALSE0 typedef int Data; typedef struct _node { Data data; struct _node * next; } Node; typedef struct _CLL { Node * tail; Node * cur; Node * before; int numOfData; } CList; typedef CList List; void ListInit(List * plist); void LInsert(List * plist, Data data); void LInse..
[C언어] 백준 5639번 이진 검색 트리 *이 포스트에서 문제의 답안은 C언어로 구성했습니다. 백준 사이트 프로그래밍 문제 c언어 답안 #include #include typedef int BTData; typedef struct _bTreeNode { BTData data; struct _bTreeNode * left; struct _bTreeNode * right; } BTreeNode; typedef void VisitFuncPtr(BTData data); BTreeNode * MakeBTreeNode(BTData data) { BTreeNode * nd = (BTreeNode*)malloc(sizeof(BTreeNode)); nd->data = data; nd->left = NULL; nd->right = NULL; return nd; ..
[C언어] 반복문 printf 출력에서 마지막엔 \n(줄바꿈) 안하게 하기 for (int i = 0;i
[c언어]에서 strlen()를 대체할 수 있는 방법.c c언어에서는 string이 없습니다. 그래서 열받는데 strlen을 써서 문자열 ( char a[100000]=""; ) 안에 입력된 널값 제외한 길이를 구할 수 있는데 이건 생각보다 프로그램 구동 시간을 엄청 잡아먹습니다. 몇몇 프로그래밍 문제는 시간 제한을 요구하기 때문에 적절하지 않습니다. 제가 생각해낸 방법을 올려봅니다. 그건 for(int i=0; i