์ „์ฒด ๊ธ€

์ „์ฒด ๊ธ€

    c++ ๋ฐฐ์—ด ์˜ค๋ฆ„์ฐจ์ˆœ ๋‚ด๋ฆผ์ฐจ์ˆœ ๊ตฌํ˜„

    ๋ฐฐ์—ด ์†์— ์—ฌ๋Ÿฌ ๊ฐ’์ด ๋’ค์ฃฝ๋ฐ•์ฃฝ ์„ž์—ฌ ์žˆ์„ ๋•Œ, ์ด๊ฒƒ๋“ค์ด ์˜ค๋ฆ„์ฐจ์ˆœ(์ž‘์€ ๊ฐ’์ด ๊ฐ€์žฅ ์•ž์— ์˜ค๊ณ  ๋ฐฐ์—ด ๋’ท ์ธ๋ฑ์Šค๋กœ ๊ฐˆ์ˆ˜๋ก ์ธ๋ฑ์Šค ๊ฐ’์ด ์ปค์ง)์œผ๋กœ ์ •๋ ฌ๋˜๋„๋ก ์ด์ค‘ํฌ๋ฌธ์„ ์จ์„œ ์ง์ ‘ ํ•˜๋“œ์ฝ”๋”ฉ์œผ๋กœ ๊ตฌํ˜„ํ•ด๋ณด์•˜๋‹ค. ๊ฐ์ข… ์ •๋ ฌ ๊ธฐ๋ฒ•์„ ๋ฐฐ์šฐ๊ณ  ๋‚˜๋ฉด ์ฝ”๋“œ๊ฐ€ ๋‹ฌ๋ผ์งˆ ๊ฒƒ์ด๋‹ค. #include using namespace std; int main() { int num[10] = { 986,4,7,12,45,895,3,7,34,5 }; for (int i =0; i+1

    [c++] ์ฝ”๋”ฉํ…Œ์ŠคํŠธ์—์„œ ios::sync_with_stdio; cin.tie(0); ๋ฅผ ์“ฐ๋ฉด ์ข‹์€ ์ด์œ 

    ์ž…์ถœ๋ ฅ์‹œ์— printf ๋ฐ scanf๋ฅผ ์“ฐ์ง€ ์•Š๊ณ  cout ๋ฐ cin์œผ๋กœ๋งŒ ์ž…์ถœ๋ ฅ์„ ํ•  ์ƒ๊ฐ์ด๋ผ๋ฉด, ios::sync_with_stdio(0); cin.tie(0); ๋ฅผ ์จ์ฃผ๋ฉด ์ข‹๋‹ค. ์ž…์ถœ๋ ฅ ์–‘์ด ๋งŽ์•„์ง€๋”๋ผ๋„ ์‹œ๊ฐ„์„ ๋‹จ์ถ•์‹œ์ผœ์ฃผ๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์‚ฌ์šฉ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™์ด cin๊ณผ cout ํ•˜๊ธฐ ์ „์— main ํ•จ์ˆ˜์—์„œ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ด๋‹ค. int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; getline(cin,s); cout ์ž…๋ ฅ์„ ํ•  ๋•Œ์— ๋งˆ์ง€๋ง‰ ์ž…๋ ฅ์„ ํ•˜๊ธฐ ์ „์— ์ถœ๋ ฅ ๋ฒ„ํผ๋ฅผ ๋น„์›Œ์ฃผ๊ฒŒ ๋œ๋‹ค. stream์„ tieํ•˜๋ฉด ๋‹ค๋ฅธ stream์—์„œ ์ž…์ถœ๋ ฅ์š”์ฒญ์ด ์˜ค๊ธฐ์ „์— stream์„ flush๋œ๋‹ค๋Š” ๊ฒƒ์„ ์ดํ•ดํ•œ๋‹ค๋ฉด cin.tie(0);..

    [c++] ๊ณต๋ฐฑ์„ ํฌํ•จํ•œ ๋ฌธ์ž์—ด์„ ์ž…๋ ฅํ•˜๊ธฐ ์ข‹์€ ํ•จ์ˆ˜ getline()

    [c++] ๊ณต๋ฐฑ์„ ํฌํ•จํ•œ ๋ฌธ์ž์—ด์„ ์ž…๋ ฅํ•˜๊ธฐ ์ข‹์€ ํ•จ์ˆ˜ getline()

    ์ผ๋ฐ˜ string ๋ณ€์ˆ˜์— ๊ณต๋ฐฑ์„ ํฌํ•จํ•œ ๋ฌธ์ž์—ด์„ ์ž…๋ ฅํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋‚œ๋‹ค. ๊ฐ€๋ น ์•„๋ž˜์™€ ๊ฐ™์€ main ํ•จ์ˆ˜์—์„œ k์— [๊ณต๋ฐฑ์„ ํฌํ•จํ•œ ๋ฌธ์ž์—ด] ์ด๋ผ๊ณ  ์ž…๋ ฅํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋‚œ๋‹ค. int main() { string k; cin >> k; cout

    c++ ํŠน์ • ํ•จ์ˆ˜์˜ ์ธ์ž๋กœ ๋ฐฐ์—ด์ฃผ์†Œ๋ฅผ ๋„˜๊ธฐ๋ฉด?

    ์ฃผ์†Œ๋ฅผ ๋„˜๊ฒผ๊ธฐ ๋•Œ๋ฌธ์— funcํ•จ์ˆ˜๊ฐ€ ๋๋‚˜๊ณ  ๋ฉ”์ธํ•จ์ˆ˜๋กœ ๋Œ์•„๊ฐ€๋„ funcํ•จ์ˆ˜์—์„œ ์ดˆ๊ธฐํ™”ํ•œ ๊ฐ’์œผ๋กœ ์ถœ๋ ฅ๋œ๋‹ค. #include using namespace std; void func(int arr[]) { arr[0] = 10; } int main() { int arr[3] = { 1,2,3 }; func(arr); cout

    2. [c++] ํŠน์ •๊ฐ’ ์ดํ•˜์˜ ์ˆ˜ ์ค‘์—์„œ ๊ฐ€์žฅ ํฐ 2์˜ ๊ฑฐ๋“ญ์ œ๊ณฑ๋งŒ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋งŒ๋“ค๊ธฐ

    2. [c++] ํŠน์ •๊ฐ’ ์ดํ•˜์˜ ์ˆ˜ ์ค‘์—์„œ ๊ฐ€์žฅ ํฐ 2์˜ ๊ฑฐ๋“ญ์ œ๊ณฑ๋งŒ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋งŒ๋“ค๊ธฐ

    *์ง์ ‘ ์ง  ๊ฒƒ์ž„์œผ๋กœ ๋ชฉ์ ์— ๋ณด๋‹ค ๋” ์ตœ์ ์ธ ํ•จ์ˆ˜๊ฐ€ ์กด์žฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.* - ํŠน์ •๊ฐ’ n์„ ์ž์œ ๋กญ๊ฒŒ ์ž…๋ ฅํ•˜๋ฉด, - n ์ดํ•˜์˜ ์ˆ˜ ์ค‘์—์„œ ๊ฐ€์žฅ ํฐ 2์˜ ๊ฑฐ๋“ญ์ œ๊ณฑ๋งŒ์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด๋ณด์•˜๋‹ค. ์˜ˆ์‹œ) 100์ž…๋ ฅ์‹œ 64 ์ถœ๋ ฅ 2์ž…๋ ฅ์‹œ 2์ถœ๋ ฅ 1์ž…๋ ฅ์‹œ 1์ถœ๋ ฅ #include using namespace std; int func(int* n) { int max =1; for (int i = 1; i * 2 > n; while (n > n; } int* a = &n; n = func(a); cout

    Unity์—์„œ this์˜ ์˜๋ฏธ

    ๋ณดํ†ต ์Šคํฌ๋ฆฝํŠธ๋Š” ์˜ค๋ธŒ์ ํŠธ์— ๋„ฃ๊ณ  ์“ด๋‹ค. this๋ž€ ํ•ด๋‹น ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ๋Š” ์˜ค๋ธŒ์ ํŠธ ๊ทธ ์ž์ฒด๋ฅผ ์˜๋ฏธํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ์•„๋ž˜ ์˜ˆ์ œ1๊ณผ ์˜ˆ์ œ2๋ฅผ ์ž‘์„ฑํ•˜๋ฉด, ๊ฒฐ๊ณผ์ ์œผ๋กœ ๋˜‘๊ฐ™์€ ์‹œ๊ฐ์  ํšจ๊ณผ๊ฐ€ ๋‚˜ํƒ€๋‚œ๋‹ค. using System.Collections; using System.Collections.Generic; using UnityEngine; public class studyScript : MonoBehaviour { void Update() { float x = Input.GetAxis("Horizontal") * 0.05f; float y = Input.GetAxis("Vertical") * 0.05f; this.transform.Translate(new Vector2(x, y)); } } using Sys..

    Unity ๋‚œ์ˆ˜ ์ƒ์„ฑ์€ Random.Range๋ฅผ ํ™œ์šฉํ•˜์ž

    float rnd = Random.Range(0.0f, 0.5f); 0.0f~0.5f ์‚ฌ์ด์— ์ˆซ์ž๋ฅผ ๋žœ๋ค์œผ๋กœ ์ƒ์„ฑํ•˜์—ฌ ๋ณ€์ˆ˜ rnd์— ๋„ฃ์–ด์ฃผ๋Š” ์ฝ”๋“œ์ด๋‹ค. ์•„๋ž˜ ์†Œ์Šค์ฝ”๋“œ๋Š” A๋ฅผ ๋ˆ„๋ฅผ ์‹œ, 0.0~0.5 ์‚ฌ์ด์˜ ๋‚œ์ˆ˜๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ๊ฐ’์€ ๋ณ€์ˆ˜ rnd์— ์ €์žฅํ•˜๊ณ  ์˜ค๋ธŒ์ ํŠธ์˜ transform.position์— Vector3ํ˜• z๊ฐ’์„ ๋Œ€์ž…ํ•ด ์œ„์น˜๋ฅผ ๋ฐ”๊พธ๋Š” ์ฝ”๋“œ using System.Collections; using System.Collections.Generic; using UnityEngine; public class studyScript : MonoBehaviour { void Update() { if (Input.GetKeyDown(KeyCode.A)) { float rnd = Random.Range(0.0f, ..