CSES - E4590 2020 0 - Results
Submission details
Task:A + B
Sender:Javier Gutierrez Ramirez
Submission time:2020-09-08 11:02:54 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:17:9: error: no match for 'operator>>' (operand types are 'int' and 'std::ostream {aka std::basic_ostream<char>}')
     a+b >> std::cout;
     ~~~~^~~~~~
input/code.cpp:17:9: note: candidate: operator>>(int, int) <built-in>
input/code.cpp:17:9: note:   no known conversion for argument 2 from 'std::ostream {aka std::basic_ostream<char>}' to 'int'
In file included from /usr/include/c++/7/iostream:40:0,
                 from input/code.cpp:1:
/usr/include/c++/7/istream:980:5: note: candidate: template<class _Istream, class _Tp> typename std::enable_if<std::__and_<std::__not_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_istream<_Istream>, std::__is_extractable<typename std::__is_convertible_to_basic_istream<_Tp>::__istream_type, _Tp&&, void> >::value, typename std::__is_convertible_to_basic_istream<_Tp>::__istream_type>::type std::operator>>(_Istream&&, _Tp&&)
     operator>>(_Istream&& __is, _Tp&& __x)
     ^~~~~~...

Code

#include <iostream>
#include <string>
#include <sstream>

int main()
{
    int a,b;
    std::string token;
    
    if (!(std::cin >> token)) { return -1; }
    std::istringstream(token) >> a;


    if (!(std::cin >> token)) { return -1; }
    std::istringstream(token) >> b;

    a+b >> std::cout;
}