136352025-01-08 11:46:26feheristvanVirágos rét (50 pont)cpp17Forditási hiba
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector <bool> szabade;
    szabade.resize(n);
    for(int i = 0; i < n; i ++){
        cin >> szabade[i];
    }
    int db, rdb = 0;
    for(int i = 0 ; i < n; i ++){
        db = 0;
        j = i;
        if(szabade[i]){
            while(j < n and db != k){
                if(szabade[j]){
                    db ++;
                }
                j ++;
            }
            if(db == k)
                rdb ++;
        }
    }
    cout << rdb;
    return 0;
}
Forditási hiba
open /var/local/lib/isolate/444/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:13:13: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<bool>::reference')
   13 |         cin >> szabade[i];
      |         ~~~ ^~ ~~~~~~~~~~
      |         |               |
      |         |               std::vector<bool>::reference
      |         std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/12/iostream:40,
                 from main.cpp:1:
/usr/include/c++/12/istream:168:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/12/istream:168:7: note:   conversion of argument 1 would be ill-formed:
main.cpp:13:25: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool'
   13 |         cin >> szabade[i];
      |                ~~~~~~~~~^
In file included from /usr/include/c++/12/vector:65,
                 from main.cpp:2:
/usr/include/c++/12/bits/stl_bvector.h:95:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   95 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/12/istream:172:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/12/istream:172:7: note:   conversion of argument 1 would be ill-formed:
main.cpp:13:25: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'bool'
   13 |         cin >> szabade[i];
      |                ~~~~~~~~~^
/usr/include/c++/12/bits/stl_bvector.h:95:5: ...