Contents
- 1. /startLine
- 2.
- 2.1. 1회-환희, 훈 (2012-03-21)
- 2.2. 1회- (2012-03-22)
- 2.3. 2회-환희 (2012-03-26)
- 2.4. 3회-환희 (2012-3-28)
- 2.5. 3회-훈, (2012-3-28)
- 2.6. 4회-환희 (2012-4-2)
- 2.7. 4회-훈 (2012-4-3)
- 2.8. 5회-환희 (2012-4-4)
- 2.9. 5회-훈 (2012-4-5)
- 2.10. 4회- (2012-4-5)
- 2.11. 6회-환희 (2012-4-9) + 7회-환희 (2012-4-9)
- 2.12. 8회 (2012-5-1) - 훈, 환희
- 2.13. 9회(2012-5-9) - 훈, 환희
- 2.14. 10회(2012-5-22) - 훈, 환희
- 2.15. 11회(2012-5-23) - 훈, 환희
- 2.16. 12회(2012-7-19)
- 2.17. 13회(2012-7-20)
- 2.18. 2012-7-30
- 2.19. 2012-8-2
2.3.2. ¶
- - 히 하 했.

int main()
{
int num1 , num2 = 1, num3, num4 = 2;
printf(" 해 해\n");
scanf("%d", &num1);
num3 = num1 - 1;
while(num2 <= num1){
while(num3 < num1){
printf("*");
num3++;
}
printf("\n");
num3 = num3 - num4;
num2 = num2 + 1;
num4++;
}
return 0;
}
2.3.3. ¶
- 환희 - 한 편하 한 했.
- - 한 (if, switch.. for...) 해 할 (switch break, ..) 환희 해 ( , python, c함) 행 행 한 했 1:1 행 편했. 환희 한 하 . C 힘 했 if for 해 . printf, scanf 헷 c 한 하 편했.
2.5.3. ¶
- 하 , 훈 함 한 확했. swap 함 행 해 했. 함 하 한 한 포 한 . 하 했 포 , call-by-value 해 하 포 효 . 통해 행 해 하 포 통해 (call-by-reference) 했. malloc 해 할하 포 해 . 표 확히 해했 . 한 표했 하, 확한 해 해 하 . 훈 C C 흥 . 해 하 하 . -
- 포 포 한 swap 함 , 환. malloc 형태 힘. malloc 한 해 . -
- 포 , 포 , malloc 함, fflush() 함, getchar() 함, heap stack , (int)a *(*(int a)) , 포 OS 크(DWORD 크 . 32bit/64bit),
해 할 - , 함 , . - 훈
2.9.2. ¶
- 포 2회. 포 해 하 typedef 해 . 함 해 . typedef int* SOMETHING 표 포 해 해 , . 히 int **twoDim twoDim0 malloc 해 한 . 해. 훈 한 (*s).age . -> * . 한 하 . . -
- 포 포, 해 , 헤 "#" 함 . 한 typedef 해 혔.
2.12.3. ¶
- 함 .
- reverse 함 하 .
했 하 함 하 하
함 . 히 함 편 합.
// . // 123 321 . 100 1 . 120 21 . int reverse(int number);
2.13.2. ¶
- Callback(winapi 하) + winapi.co.kr
함 5. + .
함 ... .
. - 환희
- 한 함 CallBack 활 .
하 해 하.
C function 해하 .
. - 훈
- 함 행했. 행 . 함 함 하 한, 한 험 한 함 행 . 히 . 함 C 한 char * 하 (함) 했 한 해 합. -
2.13.3. - ¶
- Calender.h 파 - 할 함. .
// 한 하 함.
void printCalender(int nameOfDay, int year, int month);
// (nameOfDay) 1~endDayOfMonth 합.
void printDate(int nameOfDay, int endDayOfMonth);
// 1 탭('\t') .
void printFirstTab(int nameOfDay);
// (, , 한 , 표) 합.
void printHeader(int year, int month);
// 환합.
int calculateNameOfNextMonthFirstDay(int nameOfDay, int year, int month);
// 해 환합.
int calculateNameOfLastDay(int nameOfDay, int year, int month);
// 크.
bool isLeapYear(int year);
// 환합.
// 한 switch-case , 2 해 크 합.
int endDayOfMonth(int year, int month);
// 환합. (ex. 0-"Sun", 1-"Mon" ...)
// 한 switch-case .
char *printMonthName(int i);
- main.cpp 파
#include <stdio.h>
#include "Calender.h"
int main(int argc, char *args[]) {
// year (nameOfDay) .
int year = 0, nameOfDay = 0;
printf("Enter the year : ");
scanf("%d", &year);
printf("Enter the name of day(0:sun ~ 6:sat) : ");
scanf("%d", &nameOfDay);
// 1~12 하 .
for ( int month = 1; month <= 12; month++ ) {
printCalender(nameOfDay, year, month);
nameOfDay = calculateNameOfNextMonthFirstDay(nameOfDay, year, month);
}
return 0;
}
- sample output - 1 12. 하 탭('\t') .
January, 2012
-------------------------------------------------
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
2.13.4. ¶
- strcat(str1, str2) 한 str1 트했 한 .
People p; strcat . p 화(People p = {0};) 하 하
p.name . strcat 하 p.name (p.name99 ) "홍" .
황 하 해 p 화 하 하 memset(p.name, 0, sizeof(char)*100); 하 .
#include <stdio.h>
#include <string.h>
typedef struct People{
char gender;
int age;
char name[100];
char real_name[100];
} People;
int main()
{
char str1[100] = "abc";
char str2[100] = "aaa";
People p;
strcat(p.name, "홍");
strcat(str1, str2);
printf("%s", str1);
getchar();
return 0;
}
2.14.1. ¶
- 하
한 .
- 하 .
addAccount() deleteAccount() 한 하 포트 .
#include <stdio.h>
typedef struct Account {
char *name;
int money;
} Account;
typedef struct AccountArray {
struct Account **accounts;
int currentAccountNumber;
int maxLength; // 할 하 편하.
} AccountArray;
Account *createAccount(char *name); // Account 하 할하 해 함 할 .
AccountArray *createAccountArray(int maxLength);
void addAccount(AccountArray *accountArray, char *name);
bool isFull(AccountArray *accountArray); // 하 ??????
AccountArray *extendArray(AccountArray *before); // 확 해 합.
void deleteAccount(AccountArray *accountArray, char *name); // ? ?
void deposit(AccountArray *accountArray, char *name, int money); // accountArray 할 .
void withdraw(AccountArray *accountArray, char *name, int money);
void addAccountMenu();
void deleteAccountMenu();
void depositMenu();
void withdrawMenu();
main.cpp
#include <stdio.h>
#include "Account.h"
int main(int argc, char *argv[]) {
int select = 0;
// 할 .
while ( true ) {
printf("select menu : ");
printf("1: \n");
printf("2: \n");
printf("3: \n");
printf("4: \n");
scanf("%d", &select);
switch ( select ) {
case 1:
addAccountMenu();
break;
case 2:
deleteAccountMenu();
break;
case 3:
depositMenu();
break;
case 4:
withdrawMenu();
break;
default:
break;
}
}
return 0;
}
2.15.1. ¶
////////////////////////////////////// , + 포 char a; // a ? 1. a . a = ?? // 한 화 해 . int b; // b ? 1. b . b = ?? // 한 화 해 . char c[10]; // c ?, 1. 0 화 해 ., 2. 해 화 해 ., 3. c[0] ? char *d; // d ? char 10 화 해 . // c d . . ??? // [] 해 c 해 . ??? // 한 d 해 . ??? // 한 c 해 . // array[0] == *(array + 0) 포 해 한 하 할 . //////////////////////////////////////// , + 포 Person p; // p ? 1. p . ??? // p 해. Person pArr[10]; // pArr ? 1. pArr . ??? // pArr 0 해 Person *p2; // p2 ? 1. p2 . ??? // p2 화 해 . ??? // p2 해. Person *ppa[10] // ppa ? 1. ppa ., 2. ppa[0] ? 3. ppa[0] 화 해 . 4. ppa[0] 해 . Person **ppb // ppb ? 1. ppb ., 2. ppb[0] ? 3. ppb[0] 화 해 ., 4. ppb[0] 해 .
2.16.1. ¶
- AccountArray 함 .
- createAccount(char *name) Account * 환하.
Account makeAccount(char *name) {
Account account;
account.money = 0;
account.name = (char *)malloc(sizeof(char) * (strlen(name)+1));
strcpy(account.name, name);
return account;
}
void addMoney(Account account, int money) {
account.money += money;
}
Account 환하 함 .Account call-by-value Account money 키
Account 화 .
- extendArray 함 편함.
2.17.1. ¶
- .
- LinkedList .
- ArrayList(Array) LinkedList .
- LinkedList 할 하 ( ).
- LinkedList.h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef int Data;
typedef struct Node {
Data data;
Node *nextNode;
} Node;
typedef struct LinkedList {
int length;
Node *headNode;
} LinkedList;
LinkedList *createList();
Node *createNode(Data data);
void deleteList(LinkedList *linkedList); // LinkedList .
void addData(LinkedList *linkedList, Data data); // LinkedList Data Node .
void removeData(LinkedList *linkedList, Data data); // 해하 Data Node .
Node *getData(LinkedList *linkedList, int position); // 해하 index Node 환.
void clearList(LinkedList *linkedList); // LinkedList Node .
void printList(LinkedLIst *linkedList);
2.17.2. ¶
- 환희
- 훈
#include "LL.h"
LinkedList *createList(){
LinkedList *res;
res = (LinkedList *)malloc( sizeof(LinkedList) );
(*res).headNode = NULL;
(*res).length = 0;
return res;
}
Node *createNode(Data data){
Node *res;
res = (Node *)malloc( sizeof(Node) );
(*res).data = 0;
(*res).nextNode = NULL;
return res;
}
void deleteList(LinkedList *linkedList){
clearList(linkedList);
free(linkedList);
}
void addData(LinkedList *linkedList, Data data){
Node *node = createNode( data );
Node *temp = linkedList->headNode;
for(;temp->nextNode != NULL;){
temp = temp->nextNode;
}
temp->nextNode = node;
}
void removeData(LinkedList *linkedList, Data data){
int onoff = 0; //for duty of switch
Node *remove = linkedList->headNode;
if( remove->data == data ){
free( remove ); //If the object is headNode
onoff = 1;
}
if( onoff == 0 && remove->nextNode->data == data ){
free( remove->nextNode ); //If the object is the nextNode of headNode
onoff = 1;
}
for(; onoff == 0 && remove->nextNode->data != data;){ //...
remove = remove->nextNode;
}
remove->nextNode = remove->nextNode->nextNode; // remove remove-n remove-n-n
free(remove->nextNode); // remove ~ remove-n-n , free remove-n
}
Node *getData(LinkedList *linkedList, int position){
Node *get = linkedList->headNode;
for( int i = 0 ; i < position ; i++ ){
get = get->nextNode;
}
return get;
}
void clearList(LinkedList *linkedList) {
Node *now = (*linkedList).headNode;
Node *next;
for( ; (*now).nextNode != NULL ; ){ //now
next = (*now).nextNode; //next now
free( now ); //now free
now = next; //next now
}
free( now ); //now free
}
int lengthOf(LinkedList *linkedList){
int length = 0;
Node *temp = linkedList->headNode;
for( ; temp->nextNode != NULL ; length++ ){
temp = temp->nextNode;
}
return length;
}
void printList(LinkedList *linkedList){
Node *temp = linkedList->headNode;
for( ; temp->nextNode != NULL ; ){
printf("%d\t", temp->data);
temp = temp->nextNode;
}
printf("\n");
}
2.18.1. ¶
int main() {
Stack *stack = createStack();
assert(stack->elementNumber == 0);
assert(stack->head == NULL);
push(stack, 10);
assert(stack->elementNumber == 1);
assert(peek(stack)->data == 10);
push(stack, 20);
assert(stack->elementNumber == 2);
assert(peek(stack)->data == 20);
assert(pop(stack)->data == 20);
assert(stack->elementNumber == 1);
Node *result = pop(stack);
assert(result->data == 10);
assert(isEmpty(stack));
return 0;
}










