1
文字列を持つプログラムを書いています。その後、文字列を読んで、ベクトルを使って配列にすべての数字を入れてから、その配列の中で同じ数を数えると、その数を星として出力します。文字列内の同じ数字を数え、星印として出力します。C++
エラーバイナリ表現に無効なオペランドがあります。
ここにコードがあります。
#include <iostream>
#include <vector>
#include <algorithm>
#include<array>
using namespace std;
int main() {
vector<string> array;
string grades = "01211342111153332211111232454444";
int newarray[31];
for(int i = 0 ; i < grades.length(); i++){
array.push_back(grades.substr(i,1));
}
int zero = count(std::begin(array),std::end(array),0);
int one = count(std::begin(array),std::end(array),1);
int two = count(std::begin(array),std::end(array),2);
int three = count(std::begin(array),std::end(array),3);
int four = count(std::begin(array),std::end(array),4);
int five = count(std::begin(array),std::end(array),5);
// also used this way int zero = count(array.begin(),array.end(),0); but still getting error.
for(int i = 0 ; i < one ; i ++){
cout << '1 - ' << '*' << ' ';
}
for(int j = 0 ; j < two ; j++){
cout << '2 - ' << '*' << ' ';
}
}
C++を学ぶことで、人々は私にとって少し楽になります。
感謝を!!!!! :D説明も素晴らしかったです:D –