This code gives me an error and i really dont know why, please help :)
The input is a 2d array and i want to see how many times each element appears, for storing the value and the number count i use a 2d array that acts like a list, v[i][0] being the value and v[i][1] being the count for that value #include <iostream> #include <fstream> using namespace std; ifstream in("k.in"); ofstream out("k.out"); int main() { int n,m,ii=1; in>>n>>m; int arr[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) in>>arr[i][j]; int v[n*m][2]; for(int i=0;i<n*m;i++) v[i][0]=0,v[i][1]=0; v[0][0]=arr[0][0]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) for(int l=0;l<ii;l++) if(arr[i][j]==v[l][0])v[l][1]++; else v[ii][0]=arr[i][j],v[ii][1]=1,ii++; for(int i=0;i<ii;i++) out<<v[i][0]<<' '<<v[i][1]<<endl; return 0; }