質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

解決済

1回答

910閲覧

多次元配列に関する問題で,エラーの原因が不明

退会済みユーザー

退会済みユーザー

総合スコア0

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2021/11/24 09:59

前提・実現したいこと

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 << " ") } } } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

cout << vec.at(i).at(j) = 'o';

これだと
( cout<<vec.at(i).at(j) ) = 'o'; という話になるので.

cout << ( vec.at(i).at(j) = 'o' ); のようにすれば良いかと.

投稿2021/11/24 10:16

fana

総合スコア11708

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問