/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'int main()':
foo.cc:15:12: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'char [n]')
   15 |         cin>>samp;
      |         ~~~^~~~~~
      |         |    |
      |         |    char [n]
      |         std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/iostream:42,
                 from foo.cc:1:
/usr/include/c++/13/istream:325:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
foo.cc:15:14: error: cannot bind non-const lvalue reference of type 'void*&' to an rvalue of type 'void*'
   15 |         cin>>samp;
      |              ^~~~
/usr/include/c++/13/istream:201:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
foo.cc:15:14: error: invalid conversion from 'char*' to 'long long unsigned int' [-fpermissive]
   15 |         cin>>samp;
      |              ^~~~
      |              |
      |              char*
foo.cc:15:14: error: cannot bind rvalue '(long long unsigned int)((char*)(& samp))' to 'long long unsigned int&'
/usr/include/c++/13/istream:197:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
foo.cc:15:14: error: invalid conversion from 'char*' to 'long long int' [-fpermissive]
   15 |         cin>>samp;
      |              ^~~~
      |              |
      |              char*
foo.cc:15:14: error: cannot bind rvalue '(long long int)((char*)(& samp))' to 'long long int&'
/usr/include/c++/13/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
foo.cc:15:14: error: invalid conversion from 'char*' to 'long unsigned int' [-fpermissive]
   15 |         cin>>samp;
      |              ^~~~
      |              |
      |              char*
foo.cc:15:14: error: cannot bind rvalue '(long unsigned int)((char*)(& samp))' to 'long unsigned int&'
/usr/include/c++/13/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
foo.cc:15:14: error: invalid conversion from 'char*' to 'long int' [-fpermissive]
   15 |         cin>>samp;
      |              ^~~~
      |              |
      |              char*
foo.cc:15:14: error: cannot bind rvalue '(long int)((char*)(& samp))' to 'long int&'
/usr/include/c++/13/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:184:7: note:   conversion of argument 1 would be ill-formed:
foo.cc:15:14: error: invalid conversion from 'char*' to 'unsigned int' [-fpermissive]
   15 |         cin>>samp;
      |              ^~~~
      |              |
      |              char*
foo.cc:15:14: error: cannot bind rvalue '(unsigned int)((char*)(& samp))' to 'unsigned int&'
/usr/include/c++/13/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  181 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/13/istream:181:7: note:   conversion of argument 1 would be ill-formed:
foo.cc:15:14: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   15 |         cin>>samp;
      |           

Code

#include <iostream>
using namespace std;

//SAYED AL MAMUN_LU

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        char samp[n];
        cin>>samp;
        
        int hop = sizeof(samp);
        int sum = 0;
        for(int i = 0; i < hop - 1; i++)
        {
            for(int j = i + 1; j < hop; j++)
            {
                if(samp[i] == samp[j])
                {
                    sum++;
                    
                }
            }
        }
        
        cout<<2*sum<<endl;
        
        
    }
}

Information

Submit By
Type
Submission
Problem
P1038 Do not touch my string
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 17:45:31
Judged At
2024-11-11 03:31:56
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes