diff --git "a/Turtle-hwan/chapter01/chapter01_wsl\355\231\230\352\262\275\352\265\254\354\266\225.png" "b/Turtle-hwan/chapter01/chapter01_wsl\355\231\230\352\262\275\352\265\254\354\266\225.png" new file mode 100644 index 0000000..3f1d270 Binary files /dev/null and "b/Turtle-hwan/chapter01/chapter01_wsl\355\231\230\352\262\275\352\265\254\354\266\225.png" differ diff --git "a/Turtle-hwan/chapter02/chapter02_\354\236\220\353\243\214\355\230\225.png" "b/Turtle-hwan/chapter02/chapter02_\354\236\220\353\243\214\355\230\225.png" new file mode 100644 index 0000000..63984c9 Binary files /dev/null and "b/Turtle-hwan/chapter02/chapter02_\354\236\220\353\243\214\355\230\225.png" differ diff --git a/Turtle-hwan/chapter02/variables b/Turtle-hwan/chapter02/variables new file mode 100755 index 0000000..4519e1a Binary files /dev/null and b/Turtle-hwan/chapter02/variables differ diff --git a/Turtle-hwan/chapter02/variables.c b/Turtle-hwan/chapter02/variables.c new file mode 100644 index 0000000..828b479 --- /dev/null +++ b/Turtle-hwan/chapter02/variables.c @@ -0,0 +1,23 @@ +#include + +void main() { + int example = 78; + // 서로 다른 자료형의 변수 3개 이상 선언 및 초기화 + + char example_char = 'A'; //문자형 변수 1byte / %c로 출력 / 정수로 출력하려면 %hhd + + float example_float = 2.71828182846; //4byle 단일 정밀도 + + double example_double = 2.71828182846; //8byte 두배정밀도 실수 표현 / scanf 시는 double 형은 %lf로 받아야 함. + + + + printf("%d\n", example); + // 앞서 선언한 모든 변수를 한 줄에 하나씩 출력 + printf("문자 출력 : %c | 정수 출력 : %hhd\n", example_char, example_char); + + printf("float 표현 %%1.16f 출력: %1.16f | %%f 출력: %f\n", example_float, example_float); + //float 형식은 double 보다 부정확 + printf("double 표현 %%1.16f 출력: %1.16f | %%f 출력: %f\n", example_double, example_double); + //%f로 출력하면 float이 정확하게 표시할 수 있는 한계만큼 (소수점 아래 6자리 정도) 표현?! +} \ No newline at end of file diff --git "a/Turtle-hwan/chapter03/chapter03_\354\227\260\354\202\260\354\236\220.png" "b/Turtle-hwan/chapter03/chapter03_\354\227\260\354\202\260\354\236\220.png" new file mode 100644 index 0000000..eb4e150 Binary files /dev/null and "b/Turtle-hwan/chapter03/chapter03_\354\227\260\354\202\260\354\236\220.png" differ diff --git a/Turtle-hwan/chapter03/operator b/Turtle-hwan/chapter03/operator new file mode 100755 index 0000000..7625324 Binary files /dev/null and b/Turtle-hwan/chapter03/operator differ diff --git a/Turtle-hwan/chapter03/operator.c b/Turtle-hwan/chapter03/operator.c new file mode 100644 index 0000000..cc4f99f --- /dev/null +++ b/Turtle-hwan/chapter03/operator.c @@ -0,0 +1,88 @@ +#include + + +void printBin_dec(int dec) { //십진수를 이진수로 바꾸어 출력 + int d; + if (dec >= 0) { + d = dec; + } + else { + d = -dec; + } + int bin[32] = {0,}; + int idx = 31; + while (d >= 2 && idx != 0) { + bin[idx] = d % 2; + idx--; + d = d / 2; + } + bin[idx] = 1; + + if (dec < 0) { //2진법 음수 처리 -> 2의 보수 표현 // 2의 보수 : 1의 보수 + 1 + for (int i = 31; i >= 0; i--) { //1의 보수 + if (bin[i] == 1) { + bin[i] = 0; + } + else { + bin[i] = 1; + } + } + if (bin[31] == 1) { // + 1 처리 + for (int i = 31; i >= 0; i--) { + if (bin[i] == 1) { + bin[i] = 0; + continue; + } + else { + bin[i] = 1; + break; + } + } + } + else { + bin[31] = 1; + } + } + + + //출력 부분 4자리씩 끊어서 + printf("%d를 이진수로 바꾼 결과입니다.\n", dec); + for (int i = 0; i < 32; i++) { + printf("%d", bin[i]); + if (i % 4 == 3) { + printf(" "); + } + } + printf("\n"); +} + +void main() { + //int dec = 0b101111; + int dec1, dec2; + + printf("연산할 첫 번째 십진수 입력 : "); + scanf("%d", &dec1); + printf("연산할 두 번째 십진수 입력 : "); + scanf("%d", &dec2); + + printBin_dec(dec1); + printBin_dec(dec2); + + printf("\n[비트 연산]\n"); + printf("\n%d & %d = %d\n", dec1, dec2, dec1 & dec2); + printBin_dec(dec1 & dec2); + + printf("\n%d | %d = %d\n", dec1, dec2, dec1 | dec2); + printBin_dec(dec1 | dec2); + + printf("\n%d ^ %d = %d\n", dec1, dec2, dec1 ^ dec2); + printBin_dec(dec1 ^ dec2); + + printf("\n~%d = %d\n", dec1, ~dec1); + printBin_dec(~dec1); + + printf("\n%d << 3 = %d\n", dec1, dec1 << 3); + printBin_dec(dec1 << 3); + + printf("\nsize of int : %ld byte\n", sizeof(dec1)); +} diff --git "a/Turtle-hwan/chapter04/chapter04_\354\241\260\352\261\264\353\254\270_A1(printGrade).png" "b/Turtle-hwan/chapter04/chapter04_\354\241\260\352\261\264\353\254\270_A1(printGrade).png" new file mode 100644 index 0000000..922c307 Binary files /dev/null and "b/Turtle-hwan/chapter04/chapter04_\354\241\260\352\261\264\353\254\270_A1(printGrade).png" differ diff --git a/Turtle-hwan/chapter04/printGrade_switch b/Turtle-hwan/chapter04/printGrade_switch new file mode 100755 index 0000000..67ded0d Binary files /dev/null and b/Turtle-hwan/chapter04/printGrade_switch differ diff --git a/Turtle-hwan/chapter04/printGrade_switch.c b/Turtle-hwan/chapter04/printGrade_switch.c new file mode 100644 index 0000000..fb4f234 --- /dev/null +++ b/Turtle-hwan/chapter04/printGrade_switch.c @@ -0,0 +1,38 @@ +#include + +void main() { + int score; + printf("점수 입력 : "); + scanf("%d", &score); + + switch ((score*2)/10) { + case 20: + case 19: + printf("%d는 A+ 입니다.\n", score); + break; + case 18: + printf("%d는 A 입니다.\n", score); + break; + case 17: + printf("%d는 B+ 입니다.\n", score); + break; + case 16: + printf("%d는 B 입니다.\n", score); + break; + case 15: + printf("%d는 C+ 입니다.\n", score); + break; + case 14: + printf("%d는 C 입니다.\n", score); + break; + case 13: + printf("%d는 D+ 입니다.\n", score); + break; + case 12: + printf("%d는 D 입니다.\n", score); + break; + default: + printf("%d는 F 입니다.\n", score); + break; + } +} \ No newline at end of file