C계열 언어의 경우 주소로 접근해서 처리를 하기 때문에 더 빠르다. 어떤 형식 어떤 크기 어떤 주소 이름까지 구닥다리 느낌으로 넣어주니까 속도가 더 빠르다
CTRL + F7 컴파일
F5 실행
#include
float와 double은 정밀도 차이고, C++은 기본적으로 double로 실수를 처리하려고 해서 실수뒤에 f를 붙여주면 float로 처리
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;
void solution(int N)
{
for (int i = 0; i < N; i++)
{
for (int j = 0; j < (N-1) - i; j++)
{
cout << " ";
}
for (int j = 0; j < i*2+1; j++)
{
cout << "*";
}
for (int j = 0; j < (N - 1) - i; j++)
{
cout << " ";
}
cout << endl;
}
for (int i = N-1; i > 0; i--)
{
for (int j = 0; j < N - i; j++)
{
cout << " ";
}
for (int j = 0; j < i * 2 - 1; j++)
{
cout << "*";
}
for (int j = 0; j < N - i; j++)
{
cout << " ";
}
cout << endl;
}
}
int main()
{
int N;
cin >> N;
solution(N);
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;
int main()
{
int x = 3;
char y = 'A';
int* ptr1 = &x;
char* ptr2 = &y;
cout << "x의 주소: " << &x << ", ptr1: " << ptr1 << endl;
cout << "y의 주소: " << (void*)&y << ", ptr2: " << (void*)ptr2 << endl;
return 0;
}
cout << "y의 주소: " << (void)&y << ", ptr2: " << (void)ptr2 << endl;
void로 캐스팅하는 부분이다.
기존 char타입을 cout에 넣으면 ostream은 char를 문자열 C-String으로 해석해서 그 주소부터 시작하는 문자들을 출력하기때문에 그냥 주소로 보라는 의미로 void*로 캐스팅합니다.

