21-08-01
- C++ 공부 시작
- 7일안에 토이 프로젝트 하나 진행해보기
- 앞으로 매일 공부한것을 기록
- c++로 알고리즘 풀이를 진행한다.
begin c++
#include <iostream>
using namespace std;
int main() {
int a;
a = 7;
int b = 3;
a = 5;
b = 10;
cout <<" a = "<< a << "b = "<< b << endl;
return 0;
}
정수형 자료형과 실수형 자료형
#include <iostream>
#include <climits>
using namespace std;
int main() {
int n_int = INT_MAX;
short n_short = SHRT_MAX;
long n_long = LONG_MAX;
long long n_llong = LLONG_MAX;
cout << "int는 " << sizeof n_int << "바이트이다." << endl;
cout << "이 바이트의 최대값은 " << n_int << " 이다." << endl;
cout << "short은 " << sizeof n_short << "바이트이다." << endl;
cout << "이 바이트의 최대값은 " << n_short << " 이다." << endl;
cout << "long은 " << sizeof n_long << "바이트이다." << endl;
cout << "이 바이트의 최대값은 " << n_long << " 이다." << endl;
cout << "long long은 " << sizeof n_llong << "바이트이다." << endl;
cout << "이 바이트의 최대값은 " << n_llong << " 이다." << endl;
unsigned int n_uint = INT_MAX;
unsigned short n_ushort = SHRT_MAX;
unsigned long n_ulong = LONG_MAX;
unsigned long long n_ullong = LLONG_MAX;
float a = 3.14;
int b = 3.14;
cout << a << " " << b << endl;
return 0;
}
문자형 자료형과 bool형 자료형
#include<iostream>
using namespace std;
int main() {
char a = 'a';
char b[] = { 'a','b','c','\0' };
bool c = -1;
bool d = 0;
cout << c << d << endl;
return 0;
}
const제한자와 데이터 형 변환
#include <iostream>
#define PIE 3.1415926535
using namespace std;
int main() {
int r = 3;
float s = r * r * PIE;
const float PIE_2 = 3.1415926535;
int r2 = 3;
float s2 = r2 * r2 * PIE_2;
cout << s << endl;
int a = 3.141592;
cout << a << endl;
char ch = 'M';
cout << (int)ch << " " << int(ch) << endl;
cout << static_cast<int>(ch) << " " << int(ch) << endl;
return 0;
}
auto
#include <iostream>
using namespace std;
int main() {
auto n = 100;
auto x = 1.5;
auto y = 1.3e12L;
int a = 3 + 2;
}