Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "log_duration.h"
- #include <iostream>
- using namespace std;
- class StreamUntier {
- public:
- // добавьте конструктор, деструктор
- // и дополнительные поля класса при необходимости
- StreamUntier(istream* wave)
- {
- tied_before_ = wave.tie(nullptr);
- }
- ~StreamUntier(){
- cin.tie(tied_before_);
- }
- private:
- ostream* tied_before_;
- };
- int main() {
- LOG_DURATION("\\n with tie"s);
- StreamUntier guard(cin);
- int i;
- while (cin >> i) {
- cout << i * i << "\n"s;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment