U E D R , A S I H C RSS

새싹교실/2012/start Line

1. /startLine

  • :
  • 람 :
  • 람 : , , ,

2.1. 1-, (2012-03-21)

2.1.1.

  • .
  • wiki .
  • 0 1 (ASCII code).
  • .
  • .
  • , (printf, scanf) (assert).
  • .

2.1.2.

  • 를 내 르는 .

2.1.3.

  • 만 말 는데, 무 내 모르는 . 느냐 느낌. . 른 방 모르만... 느낀 . -
  • -
  • 대대 -

2.2. 1- (2012-03-22)

2.2.1.

  • .
  • 는 부들(변, 문) .
  • 는 부들(, call by value, call by reference, , )

2.2.2.

  • C를 .

2.2.3.

  • - C문 는 부 , 만들, 명, gcc . . 는데 . .
  • - 는 범 . 는 모르는 .

2.3. 2- (2012-03-26)

2.3.1.

  • 1.
  • .
  • 문(문, 복문) 몇몇 들(switch문 break , 복문 등).
  • .

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.4. 3- (2012-3-28)

2.4.1.

  • .
  • /리 따른 .
  • .
  • .
  • swap .

2.4.2.

  • .

2.4.3.

  • (if문, 복문) . 를 만, . 는 만 . . 는데 scope 내부 . printf문 를 보는데 . . 모르. -

  • - 배, 배
    - 란? , 만
    - 를 받
    - ......? -

2.5. 3-, (2012-3-28)

2.5.1.

  • , .
  • swap 를 만들 .
  • 념, 메모리 .
  • malloc 메모리 .
  • .

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.6. 4- (2012-4-2)

2.6.1.

  • swap .
  • (call-by-value).
  • 념, 메모리 .
  • 문들 .

2.6.2.

  • 를 낸면 C C 문 는 만 무리 를 낼 . 만... -

2.6.3.

  • swap swap . 는 방 . 느끼는 만 call-by-value 를 들 느끼 . . 럼 malloc 는데 른 부 . 는 만 . . 는 만 C . -
  • 대략 념 - 복.
    .
    메모리 + - 변 + ... . -

2.7. 4- (2012-4-3)

2.7.1.

2.7.2.


*, & ( 는데 ..) 배..
malloc fflush
heap stack .
념만
... -

2.7.3.

  • - 배 .

//  
void reverseArr(int **arr, int arrLen);

//  
int arr[10];
reverseArr(&arr, 10);

2.8. 5- (2012-4-4)

2.8.1.

  • malloc .
  • .
  • 받는 .

2.8.2.

  • (malloc ) 메모리 (free ) . 는데, 배 메모리를 . (배)를 받는 를 만, 배 . -
  • malloc = 는 메모리, 변 는 메모리(변?)
    Pointer = .
    () 받는 = , |
    념들. -

2.9. 5- (2012-4-5)

2.9.1.

  • .
  • 미, (struct , ., typedef ).
  • 받는 (changeAge() ).
  • .

2.9.2.

  • 2. typedef . 받는 . typedef int* SOMETHING 봤는데, . int **twoDim twoDim0 malloc 는 부 . . (*s).age. -> * . 메모리 . . -
  • , , 더는 "#" . typedef .
.
  • 는데 1. 농떙 만... C를 . . -

2.10. 4- (2012-4-5)

2.10.1.

  • malloc .
  • , , typedef .
  • 받는 .

2.10.2.

  • . ( ) 는데, . 루는 . -
  • (malloc) , , typedef 리를 메모리 . , . . -

2.11. 6- (2012-4-9) + 7- (2012-4-9)

2.11.1.

  • .
  • .
  • 보는 (operation).
  • 받는 .
  • fopen() .

2.11.2.

  • .
  • , . ;;;; 는데 른 방 . () () 는데 . 런 부 . ( 등) , 만들 . . -

2.12. 8 (2012-5-1) - ,

2.12.1.

  • .
  • - 밍.
  • () .
  • .
  • 만들 (isPrime, isPalindromePrime 등).

2.12.2.

  • : 를 만. . .
    : reverse(number) -
    : ...미... , . C . 보람. -
  • ' 밍' . 복 밍 부. () 를 만 는 방. 는 부 는데, . . -

2.12.3.

  • 를 만듭.
  • reverse 만들 .
    를 만 는 부
    를 만들 . .

//  를 뒤.
// 123 면 321. 100 면 1. 120 면 21.
int reverse(int number);

2.13. 9(2012-5-9) - ,

2.13.1.

  • callback, event driven .
  • (char *) .
  • 들(str...).
  • winapi.co.kr

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. 10(2012-5-22) - ,

2.14.1.


  • 를 만들.
  • 만들 .
    addAccount() deleteAccount()는 .

Account.h
#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. 11(2012-5-23) - ,

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. 12(2012-7-19)

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. 13(2012-7-20)

2.17.1.


#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.17.3.

  • 더미 노 , .

2.18. 2012-7-30

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;
}

2.19. 2012-8-2

2.19.1.

  • Map in C - 내를 내 보 . 를 보 .


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:48
Processing time 0.0879 sec