๏ฃฟ Apple Lover Developer & Artist

์˜์†์ ์ธ ๋””์ž์ธ์— ํ˜„๋Œ€์˜ ๊ณต๊ฐ์„ ์ฑ„์›Œ๋„ฃ๋Š” ๊ณต๋ฐฉ์ž…๋‹ˆ๋‹ค

๐Ÿ–ฅ Computer Science/Programming

[C++] ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์œ„ํ•œ ํ…œํ”Œ๋ฆฟ (Cheat sheet)

singularis7 2019. 10. 5. 18:30
๋ฐ˜์‘ํ˜•

C++ ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฒฝ์ง„ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ๊ณต๋ถ€ํ•ด๋ณด๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค. ๊ฒฝ์ง„ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์ค€๋น„ํ•˜๋ฉด์„œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ•™์Šตํ•˜๊ณ  ๋ฌธ์ œ๋ฅผ ํ‘ธ๋Š”๋ฐ ๋– ์˜ฌ๋ฆด ์ˆ˜ ์žˆ๋Š” ๋Šฅ๋ ฅ๋„ ์ค‘์š”ํ•˜์ง€๋งŒ ์–ธ์–ด์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ์ ์ธ ๋ถ€๋ถ„์„ ์œ ์—ฐํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋Šฅ๋ ฅ ๋˜ํ•œ ์ค‘์š”ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ฐธ๊ณ ํ•˜์—ฌ ํ”„๋กœ๊ทธ๋žจ์˜ ์ˆ˜ํ–‰ ๊ฒฐ๊ณผ๋ฅผ ๊ฐœ์„ ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” ๋‚ด์šฉ์„ ์ด ๊ฒŒ์‹œ๊ธ€์— ๋ชจ์•„๋‘๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค.

Template Code

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main ()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

  cout << "Hello World" << '\n';

  return 0;
}

Online Judge Site

์œ ๋ช… ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฌธ์ œํ’€์ด ์‚ฌ์ดํŠธ๋ฅผ ๋ชจ์•„๋ดค์Šต๋‹ˆ๋‹ค.

ํ•ด์™ธ

  1. Codeforces
  2. TopCoder
  3. LeetCode
  4. CODECHEF

๊ตญ๋‚ด

  1. ๋ฐฑ์ค€ ์˜จ๋ผ์ธ ์ €์ง€(BOJ)
  2. ์ฝ”๋“œ์—…(CodeUp)
  3. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค(Programmers)
  4. ์‚ผ์„ฑ SW Expert Academy

Tip

  1. g++ ์ปดํŒŒ์ผ๋Ÿฌ๋กœ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์ปดํŒŒ์ผํ•˜๋ ค๋ฉด? (์˜ˆ: test.cpp)
    • g++ -std=c++11 -02 -Wall test.cpp -o test
  2. cout ์ŠคํŠธ๋ฆผ์„ ์ด์šฉํ•  ๋•Œ, ์ข€๋” ํšจ์œจ์ ์œผ๋กœ ์ž…์ถœ๋ ฅ์„ ํ•˜๋ ค๋ฉด?
    • ios::sync_with_stdio(0);
    • cin.tie(0)
    • cout << endl; (X) -> cout << '\n'; (O)
  3. ๋ถ€๋™์†Œ์ˆ˜์  ์ถœ๋ ฅ ์ž๋ฆฌ์ˆ˜ ์กฐ์ •ํ•˜๋ ค๋ฉด? (์˜ˆ: ์†Œ์ˆ˜์  ์•„๋ž˜ 9์ž๋ฆฌ๊นŒ์ง€ ํ‘œํ˜„)
    • printf("%.9f\n", integer);
    • cout << fixed;
    • cout << setprecision(9);
  4. ์ฝ”๋“œ๋ฅผ ์ค„์ด๊ณ  ์‹ถ๋‹ค๋ฉด?
    • typedef ํ˜น์€ #define(๋งคํฌ๋กœ) ํ™œ์šฉํ•ด๋ณด๊ธฐ
  5. ์ผ๋ฐ˜์ ์œผ๋กœ ์—ฐ์‚ฐํšŸ์ˆ˜๊ฐ€ 5์–ต์„ ๋„˜์–ด๊ฐ€๋Š”๊ฒฝ์šฐ
    • C์–ธ์–ด(13์ดˆ) Python(515์ดˆ)=> ๊ฐ€๋Šฅํ•˜๋ฉด pypy๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Œ
    • N <= 500 => O(N^3), N<=2,000 => O(N^2)
    • N <= 100,000 => O(NlogN)
    • N <= 10,000,000 => O(N)
  6. ์˜จ๋ผ์ธ IDE๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๊ณ  ์‹ถ๋‹ค๋ฉด?

Book Reference

๋ฐ˜์‘ํ˜•

'๐Ÿ–ฅ Computer Science > Programming' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[์•Œ๊ณ ๋ฆฌ์ฆ˜] ๋ฐฑ์ค€ 16236 ์•„๊ธฐ์ƒ์–ด  (0) 2020.08.23
[C++] ๋ณด๊ด€ํ•จ  (0) 2019.10.19
[C++] ์ •๋ ฌ (Sorting)  (0) 2019.10.19