공순이의 블로그

고정 헤더 영역

글 제목

메뉴 레이어

공순이의 블로그

메뉴 리스트

  • 홈
  • 태그
  • 방명록
  • 분류 전체보기 (109)
    • 머신러닝 (13)
    • 파이썬 (26)
    • cmd (3)
    • terminal (22)
    • Pandas (1)
    • rviz (1)
    • c++ (8)
    • 문서 (4)
    • tensorflow (2)
    • Cakewalk (1)
    • IT 용어 (1)
    • PyTorch (3)
    • photoshop (1)
    • VSCode (2)
    • 3D Printing (1)
    • java (2)
    • OpenGL (1)
    • git (2)
    • MSYS2 (1)
    • React (0)
    • Mesh Segmentation (0)

검색 레이어

공순이의 블로그

검색 영역

컨텐츠 검색

c++

  • 원형 큐 c++로 만들기

    2020.12.10 by Riella

  • Convert Binary Number in a Linked List to Integer (Day 1)

    2020.11.01 by Riella

  • cin, getline skipping input

    2020.09.03 by Riella

  • 비주얼 스튜디오에서 MinGW를 이용해 c++파일 컴파일하기 (Run c++ file in Visual Studio Code using MinGW)

    2020.08.28 by Riella

  • Int to string, string to char* in c++

    2020.07.19 by Riella

  • Stringstream: cuts the string into parts by space

    2020.07.19 by Riella

  • Ternary if statement

    2020.07.19 by Riella

  • Double to int cast

    2020.07.18 by Riella

원형 큐 c++로 만들기

우선 원형 큐(Queue)에 들어갈 노드(Node)부터 정의를 하였다 (linked list로 원형 큐 구현함) #include using namespace std; // Node that will go inside of circular queue struct Node { string name; int items; Node *next; Node(string n, int i, Node *nextNode=nullptr): name(n), items(i), next(nextNode) {}; }; 노드에는 데이터와 다음 노드로 이어주는 next가 있다. 데이터 부분은 이름과 아이템 개수로 정의 했으며 next는 노드를 가리키는 포인터이다. 그 후 constructor를 구현했는데, 스트링과 정수를 받으면 포인터..

c++ 2020. 12. 10. 14:24

Convert Binary Number in a Linked List to Integer (Day 1)

11월에 들어 LeetCode Challenge를 매일 해보고 싶어서 블로그 글을 쓰게 됬습니다. 좀 취약하다고 생각하는 C++를 이용하여 코딩을 해보려고 합니다. Reference: leetcode.com/explore/featured/card/november-leetcoding-challenge/564/week-1-november-1st-november-7th/3516/ 답을 기제할 생각은 없고 이 문제 안에 쓰인 개념들을 정리해볼까 했지만 결국 제가 제출한 코드를 적었습니다. 밑에 답이 있으니 혼자 힘으로 풀고 싶은 분들은 맨 밑은 보지 마시길 바랍니다. head가 있으면 val과 next를 구할 수 있는 형태의 Linked List입니다. 우선 val의 타입이 어떤지 알기 위해 쓴 메소드 입니다...

c++ 2020. 11. 1. 23:46

cin, getline skipping input

Reference: https://rainflys.tistory.com/75 Code Reference: https://www.cprogramming.com/tutorial/lesson6.html Reference 2: https://jhnyang.tistory.com/107 여기에도 정말 잘 설명되어있다. #include using namespace std; int main() { int x; // A normal integer int *p; // A pointer to an integer p = &x; // Read it, "assign the address of x to p" cin>> x; // Put a value in x, we could also use *p here cin.ignore();..

c++ 2020. 9. 3. 12:25

비주얼 스튜디오에서 MinGW를 이용해 c++파일 컴파일하기 (Run c++ file in Visual Studio Code using MinGW)

Reference: https://code.visualstudio.com/docs/cpp/config-mingw 1. 비주얼 스튜디오 코드 왼쪽에 블럭 표시 클릭 -> 'C/C++ extension for VS Code' 검색해서 다운받는다. 2. https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download 여기에서 installer을 다운 받고 실행, Architecture은 x86_64를 누른후 다음.. 다음을 눌러서 다운 받는다. 3. 하단의 돋보기 클릭, 환경 변수 검색을 해서 시스템 환..

c++ 2020. 8. 28. 22:15

Int to string, string to char* in c++

#include #include #include #include using namespace std; int main() { char* arr [10]; int count = 0; string inp; //stringstream ss;

c++ 2020. 7. 19. 20:47

Stringstream: cuts the string into parts by space

Stringstream gets the input of string (line). Then it cuts based on space. I used it when getting rows of integer in one line, cut by one number(formatted in string) using stringstream, and changed into int using atoi( [name_of_string].c_str()) using a while loop. I used atoi( [].c_str) because the version of c++ was below 11. This is the sample code: #include #include #include //for stringstrea..

c++ 2020. 7. 19. 00:54

Ternary if statement

There is a short way to write if statement: ternary if statement. The format is that (condition) ? [if true, here] : [if false, here] When using in cout, make sure to use parenthesis like below code. #include #include #include using namespace std; int main() { string weather = "sunny"; double humid = 0.7; weather = (humid > 0.5) ? "rainy" : "sunny"; cout

c++ 2020. 7. 19. 00:45

Double to int cast

처음에 n = 10이라 정의하고 m = 100이라 정의를 한 다음에 간단한 if문을 만들어서 pow(n, 2) (n의 제곱) 과 m이 같은 수인지 확인하였다. 하지만 알다시피 pow(a, b)의 타입은 double이다. 그래서 (int) pow(n, 2)를 해서 비교를 했더니 ...??? 99가 되는것이었다. 찾아보니 수가 0보다 크면 0.5를 더하고 0보다 작으면 0.5를 빼라고.. 그래서 위에 ROUND_2_INT(f) 라는 함수를 정의 해줬다. (물론 제일 쉬운 방법은 round() 함수를 쓰는것이다 ㅋㅋㅋ) #include #include #include #include #define ROUND_2_INT(f) ((int) (f >= 0.0 ? (f+0.5):(f-0.5))) //when usin..

c++ 2020. 7. 18. 18:16

추가 정보

인기글

최신글

페이징

이전
1
다음
TISTORY
공순이의 블로그 © Magazine Lab
페이스북 트위터 인스타그램 유투브 메일

티스토리툴바