+ 2
Which one is better in cpp compiler?
cin and cout OR scanf and printf? Which one is better and why?
7 odpowiedzi
+ 5
Ashfaq Reshad in competitive programming cin and cout is almost 5 times slower than printf() and scanf() but you can still use cin/cout and achieve the same speed as scanf/printf by including the following two lines in your main() function👇
ios_base::sync_with_stdio(false);
cin.tie(NULL);
Learn more about it here👇
https://www.geeksforgeeks.org/fast-io-for-competitive-programming/amp/
+ 2
Ninja Coder
Arsenic
Thank you both <3
+ 1
You shouldn't use scanf() over cin if you are writing C++ software because that is want cin is for. If you want performance, you probably wouldn't be writing I/O in C++ anyway. The statements cin and cout in general use seem to be slower than scanf and printf in C++, but actually they are FASTER!
0
As I know cin and cout is for C++, rest are for C. These are standard.
0
Ninja Coder people says that cin & cout is slower than scanf & printf
0
Ninja Coder in terms of competitive programming which one is better?
If cin & cout is slow i may have to go with time limit exceeded problem...
0
Ashfaq Reshad Sorry, I have no answer for that. You should google it for the best answer