fork download
  1. #include <math.h>
  2. #include <string>
  3. using namespace std;
  4.  
  5. bool returnpingPong(int n)
  6. {
  7. string st;
  8. for (int i = 1; i <n; i++)
  9. {
  10. if (i % 21 = 0)
  11. {
  12. st.append("PingPong");
  13. }
  14. if (i % 3 = 0)
  15. {
  16. st.append("Ping");
  17. }
  18. if (i % 7 = 0)
  19. {
  20. st.append("Pong");
  21. }
  22. else
  23. {
  24. st.append(i);
  25. }
  26. }
  27. cout << st;
  28. }
  29.  
  30. int main () {
  31. int n;
  32. cin >> n;
  33. returnpingPong(n);
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘bool returnpingPong(int)’:
prog.cpp:10:20: error: lvalue required as left operand of assignment
       if (i % 21 = 0)
                    ^
prog.cpp:14:19: error: lvalue required as left operand of assignment
       if (i % 3 = 0)
                   ^
prog.cpp:18:19: error: lvalue required as left operand of assignment
       if (i % 7 = 0)
                   ^
prog.cpp:24:15: error: no matching function for call to ‘std::__cxx11::basic_string<char>::append(int&)’
    st.append(i);
               ^
In file included from /usr/include/c++/6/string:52:0,
                 from prog.cpp:2:
/usr/include/c++/6/bits/basic_string.h:1125:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] <near match>
       append(const _CharT* __s)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1125:7: note:   conversion of argument 1 would be ill-formed:
prog.cpp:24:15: error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
    st.append(i);
               ^
In file included from /usr/include/c++/6/string:52:0,
                 from prog.cpp:2:
/usr/include/c++/6/bits/basic_string.h:1083:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       append(const basic_string& __str)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1083:7: note:   no known conversion for argument 1 from ‘int’ to ‘const std::__cxx11::basic_string<char>&’
/usr/include/c++/6/bits/basic_string.h:1100:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]
       append(const basic_string& __str, size_type __pos, size_type __n)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1100:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/6/bits/basic_string.h:1112:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]
       append(const _CharT* __s, size_type __n)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1112:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/6/bits/basic_string.h:1142:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]
       append(size_type __n, _CharT __c)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1142:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/6/bits/basic_string.h:1152:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       append(initializer_list<_CharT> __l)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1152:7: note:   no known conversion for argument 1 from ‘int’ to ‘std::initializer_list<char>’
/usr/include/c++/6/bits/basic_string.h:1171:9: note: candidate: template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
         append(_InputIterator __first, _InputIterator __last)
         ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1171:9: note:   template argument deduction/substitution failed:
prog.cpp:24:15: note:   candidate expects 2 arguments, 1 provided
    st.append(i);
               ^
prog.cpp:27:5: error: ‘cout’ was not declared in this scope
     cout << st;
     ^~~~
prog.cpp: In function ‘int main()’:
prog.cpp:32:3: error: ‘cin’ was not declared in this scope
   cin >> n;
   ^~~
stdout
Standard output is empty