C++
c++ 캐스트 연산자
c++ 캐스트 연산자
2020.10.25#include using namespace std; int main() { int x = 2; double y = 4.4; int i = static_cast(y / x); int j = int(y) / x; double k = y / x; cout
c++ 비트 연산자 이해하기
c++ 비트 연산자 이해하기
2020.10.25#include #include using namespace std; int main() { bitset bit1; bit1.reset(); // 0000 0000 bit1 = 127; // 0111 1111 bitset bit2; bit2.reset(); bit2 = 0x20; // 32 bitset bit3 = bit1 & bit2; bitset bit4 = bit1 | bit2; bitset bit5 = bit1 ^ bit2; bitset bit6 = ~bit1; bitset bit7 = bit2 > 1; cout
c++ 조건부 삼항 연산자 이해하기(? :)
c++ 조건부 삼항 연산자 이해하기(? :)
2020.10.25#include using namespace std; int main() { int x(1), y(2), z(0); z = x > y ? x : y; cout y 조건이 true 이기 때문에 x 값을 z에 할당합니다. 만약 조건이 맞지 않는다면 false 에 해당하는 y 값이 z 에 할당됩니다.
c++ 문자열형 변수 이해하기(string)
c++ 문자열형 변수 이해하기(string)
2020.10.25#include #include using namespace std; int main() { string my_country = "korea"; string my_job = "developer"; cout
c++ 문자형 변수 이해하기(char)
c++ 문자형 변수 이해하기(char)
2020.10.25#include using namespace std; int main() { char ch1 = 'c'; char ch2 = 200; unsigned char ch3 = 'c'; unsigned char ch4 = 200; printf_s("char ch1 = %c, %d\n", ch1, ch1); printf_s("char ch2 = %c, %d\n", ch2, ch2); printf_s("char ch3 = %c, %d\n", ch3, ch3); printf_s("char ch4 = %c, %d\n", ch4, ch4); return 0; } 이 자료형은 문자를 저장하며 아스키 코드값에 따라 숫자로 값을 할당할 수도 있습니다. char의 범위는 -127 ~ + 127이며 unsigned 키워드를 붙일..
c++ 사용자 정의 타입 tuple 만들기
c++ 사용자 정의 타입 tuple 만들기
2020.10.19#include #include #include using namespace std; std::tuple getTuple() { int a = 10; double d = 3.14; return std::make_tuple(a, d); } int main() { std::tuple my_tp = getTuple(); cout
c++ 문자열 테두리
c++ 문자열 테두리
2020.10.18// 이름을 묻고, 인사를 건넴 #include #include using namespace std; int main() { cout > name; // 출력하려는 메시지를 구성 const string greeting = "Hello, " + name + "!"; // 인사말의 두 번째 행과 네 번째 행 const string spaces(greeting.size(), ' '); const string second = "* " + spaces + " *"; // 인사말의 첫번째 행과 다섯 번째 행 const string first(second.size(), '*'); cout
c++ 메모하며 공부하기 - Codeup 1018 - 시간 입력받아 그대로 출력하기.
c++ 메모하며 공부하기 - Codeup 1018 - 시간 입력받아 그대로 출력하기.
2020.10.13int a 와 b 가 선언되 었고 중간에 char 타입 x 가 있다 시간을 나타낼때 13:25 의 13과 25는 숫자이고 : 는 문자열이라서 : 을 기준으로 각 변수에 담긴다. c++ 입문 22일차 오늘은 포인터 강의를 듣다가 잠시 카페에 와서 코드업 문제풀기