前提・実現したいこと
https://atcoder.jp/contests/apg4b/tasks/APG4b_ce
AtCorder の基本問題の質問です.
発生している問題・エラーメッセージ
エラーメッセージ ./Main.cpp: In function ‘int main()’: ./Main.cpp:19:37: error: no match for ‘operator=’ (operand types are ‘std::basic_ostream<char>’ and ‘char’) 19 | cout << vec.at(i).at(j) = 'o'; | ^~~ In file included from /usr/include/c++/9/istream:39, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from ./Main.cpp:1: /usr/include/c++/9/ostream:408:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator=(std::basic_ostream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]’ 408 | operator=(basic_ostream&& __rhs) | ^~~~~~~~ /usr/include/c++/9/ostream:408:33: note: no known conversion for argument 1 from ‘char’ to ‘std::basic_ostream<char>&&’ 408 | operator=(basic_ostream&& __rhs) | ~~~~~~~~~~~~~~~~^~~~~ ./Main.cpp:22:37: error: no match for ‘operator=’ (operand types are ‘std::basic_ostream<char>’ and ‘char’) 22 | cout << vec.at(i).at(j) = 'x'; | ^~~ In file included from /usr/include/c++/9/istream:39, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from ./Main.cpp:1: /usr/include/c++/9/ostream:408:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator=(std::basic_ostream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]’ 408 | operator=(basic_ostream&& __rhs) | ^~~~~~~~ /usr/include/c++/9/ostream:408:33: note: no known conversion for argument 1 from ‘cha... ### 該当のソースコード C++ ソースコード include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> A(M), B(M); for (int i = 0; i < M; i++) { cin >> A.at(i) >> B.at(i); } // ここにプログラムを追記 // (ここで"試合結果の表"の2次元配列を宣言) vector<vector<char>> vec(N, vector<char>(N)); for (int i=0; i < M; i++) { for (int j = 0; j < M; j++) { for (int k = 1; k <= M; k++){ if(i == A.at(M) && j == B.at(M)){ cout << vec.at(i).at(j) = 'o'; } else if (i == B.at(M) && j == A.at(M)) { cout << vec.at(i).at(j) = 'x'; } else {cout << vec.at(i).at(j) = '-';} } } for (int i = 0; i < M; i++){ for (int j = 0 ; j < M; j++){ cout << vec.at(i).at(j) ; if(j = N-1) { cout << endl; else(cout << " ") } } } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。