私はC++を学んでいます。私のコード内の何かが動作していないが、私は問題が何かを理解していない。私はT配列で何個の数字が繰り返されるかを数えるstat配列のインクリメントであると思います...どうすれば修正できますか?たぶん構文stat [elt] ++が間違っていますか?C++配列内で何個の数字が繰り返されているかを知る
#include <iostream>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <string>
#include <sstream>
using namespace std;
int anneeSecu(int T[12][13], int j){
// here I join the 2 numbers of tab (they refer to the year of birth) and I add the number 20, because I know that they were born all after 2000
int a = T[j][1];
int b = T[j][2];
ostringstream oss;
oss << "20" << a << b;
istringstream iss(oss.str());
int ab;
iss >> ab;
int annee = ab;
cout << annee << endl;
return annee;
}
int main(){
int T[12][13]={ {1,1,2,0,2,3,7,1,9,8,2,0,5},
{2,1,3,0,5,8,9,9,0,8,1,0,2},
{2,1,6,0,8,1,9,2,6,5,4,8,7},
{2,1,5,0,6,5,6,3,4,6,0,6,7},
{1,1,5,0,6,5,6,3,4,6,0,7,5},
{2,1,5,0,2,5,6,3,4,6,0,6,7},
{2,1,5,0,6,2,9,1,4,7,1,6,3},
{2,1,4,0,6,2,2,1,4,7,1,6,3},
{2,1,4,0,9,3,5,1,4,7,1,6,3},
{1,1,1,1,2,5,6,1,7,5,0,0,7},
{1,1,1,0,9,5,6,1,7,5,1,0,7},
{2,1,4,1,0,3,5,1,4,7,0,2,2} };
int stat[6]={0,0,0,0,0,0};
for (int i=0;i<12;i++){
int l=anneeSecu(T,i);
**stat[l]++;**
}
return 0;
}
CMDの出力と凍結エラーがSTATであっ
2012
Process returned -1073741819 (0xC0000005) execution time : 1.764 s
Press any key to continue.
液[L] ++を(それは0から5までの数字を取るため...) 補正=> STAT
int l=anneeSecu(T,i);
stat[l]++;
:コードのこの部分に問題があり、[L-2011] ++
アドバイスありがとうございます。 @ビフェン...今あなたは私を助けることができますか? – Jurafsky