Skip to content

[C++] BOJ11659 #36

@Settpark

Description

@Settpark

ios::sync_with_stdio(0);
cin.tie(0); 로 시간 초과가 나서 복습합니다.
사실 이거 쓰라고 해도 그냥 안 쓰는 경우가 많았는 데, 써야할 필요성을 느꼈습니다.
ios::sync_with_stdio(0); = printf와 cout은 각각의 스트림을 가지고 있는 데, 이를 동기화하는 과정, 이 키워드를 사용하면 두 함수를 섞어서 사용하면 안된다.
cin.tie(0); = cin을 하기전 무조건 cout을 버퍼를 비우고 시작하는 데, 이를 처리하지 않는 코드이다.
ex)

cout << "Enter name;"
cin >> name;

cin.tie(0)를 하게 되면 cout을 flush 하지 않기 때문에, "Enter name"을 출력하지 않고 cin을 처리합니다.
(cout의 버퍼가 가득 차거나 수동으로 flush 해야합니다.)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions