[C++] 백준 1568 새
·
Algorithm/Baekjoon
#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int num = 0, n, m = 1; cin >> n; while (n > 0) { if (n >= m)//부르려는 수가 새보다 적을 때 { n -= m;//총 새에 부르는 수 감소 num++; //카운트 m++; //부르는 수 증가 } else//총남은 새가 부르려는 수보다 적을 때 { m = 1; } } cout
[C++] 백준 1543 문서 검색
·
Algorithm/Baekjoon
#include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); string n; string m; int result = 0; getline(cin, n);//공백까지 단어로 포함 getline(cin, m); for (int i = 0; i < n.length();) { if (n.substr(i, m.length()) == m)//i부터 단어의 길이까지가 단어와 같나 { i += m.length();//같으면 검색한 길이만큼 제외 result++;//같은 개수 추가 } else { i++;//없으면 한 글자 추가 } } cout
DirectX 2D - Portfolio (프리스타일1 모작)
·
Game Programming/DirectX
구현사항 충돌- 서로의 캐릭터의 가로 크기만큼 발 밑의 네모박스를 두어서 충돌합니다.- 계산은 박스와 박스의 충돌식을 사용하였습니다. 슛- 현재 위치에서 골대 방향의 위로 직선으로 보내는 힘을 주고 중력을 설정하여 골대에 닿게 구현하였습니다.- 레이업과 덩크는 골대 근처 범위를 주고 골대방향으로 캐릭터가 이동하고 도착하게 설정하였습니다. 블락- 블락은 캐릭터의 손쪽에 충돌체를 주어서 공과 닿으면 블락되도록 하였습니다. 2D상의 높이해결- 높이는 가상의 y값을 두어 해결하였습니다.- 화면상의 y를 z로 두었고 점프를 하는 상황이 나왔을때 발 밑의 충돌체가 점프전의 위치로 계산을 하여  위에 캐릭터가 있더라도 가까워지지 않게 하였습니다. 그물망의 공과의 겹침해결- 그물망을 두개로 나눠 뒷쪽Render와 앞쪽..
[C++] 백준 10814 나이순 정렬
·
Algorithm/Baekjoon
#include #include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); int n; cin >> n; vector x; for (int i = 0; i > temp >> temp2; x.push_back({ temp, i, temp2 }); } sort(x.begin(), x.end()); for (int i = 0; i < n; i++) { cout
[C++] 백준 1427 소트인사이드
·
Algorithm/Baekjoon
#include #include #include using namespace std; int main() { ios::sync_with_stdio(false); string n; cin >> n; sort(n.rbegin(), n.rend()); int num = stoi(n);//string에 있는 stoi함수를 사용하여 int로 형변환한다. //s(tring)to(int) stoi로 생각 cout
[C++] 백준 1920 수 찾기
·
Algorithm/Baekjoon
#include #include #include using namespace std; int main() { set num; vector finding; int n, m, temp; cin >> n; for (int i = 0; i > temp; num.insert(temp); } cin >> m; for (int i = 0; i > temp; finding.push_back(temp); } for (auto x : finding) { cout