Блог пользователя oyu8201

Автор oyu8201, история, 7 лет назад, По-английски

I've been using iostream for c++14 for a long time. Would it be more simple if I switched to stdio.h?

  • Проголосовать: нравится
  • -7
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится -18 Проголосовать: не нравится

I first learned iostream, but I'm pretty sure stdio.h would be more simple

»
7 лет назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

Why would stdio be simpler?

iostream is very easy to use, and it's easy to make it faster by removing synchronization with the stdio library and untying std::cin and std::cout. In almost all cases, using iostream with these 2 optimizations will let your code pass the TL.

There are maybe 4 or 5 problems that I've solved that actually didn't pass with iostream. One of them is Problem J of the Arab Collegiate Programming Contest from 2010. That problem has almost 80MB of input files. I think even stdio didn't stand a chance there. I recall writing my own thing to read the input in 1KB blocks or something.

I also recall this problem: http://mirror.codeforces.com/gym/101102/problem/J I couldn't get it to pass with iostream, but stdio passed just fine.

This is pretty rare in my opinion though. Don't take it too seriously, it's one data point.

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

iostream is more extensible ... If the data type is something different like pid_t ... You don't need to find the exact formate specifier for it. The disadvantage is that it is a little slower ... However there are ways to get around it.

P.S. — You can use cstdio ... It has all of the functions in stdio.h. I use cstdio when I use printf and scanf is C++ programs.