0

Im having difficulties in performing the frequency distribution of 6x6 matrix which was given..i solved it by the following way but it was wrong anyway because if i change any number in the matrix it will not calculate the number of times it occurs in the array.... need your kind guidance as im still a beginner...

```
#include <iostream>
using namespace std;
int main()
{#include <iostream>
using namespace std;
int main()
{
int M[6][6]= {{3,14,4,10,3,6},
{5,10,3,8,3,3},
{8,3,3,8,-3,3},
{10,10,-3,3,6,-3},
{-3,-3,6,8,5,5},
{6,5,5,8,5,5}};
int n0 = -3;
int n1 = 3;
int n2 = 4;
int n3 = 5;
int n4 = 6;
int n5 = 8;
int n6 = 10;
int n7 = 14;
int count = 0;
int count1 = 0;
int count2 = 0;
int count3 = 0;
int count4 = 0;
int count5 = 0;
int count6 = 0;
int count7 = 0;
for (int i = 0; i<6; i++)
{
for (int j = 0; j <6; j++)
{
if (n0 == M[i][j])
{
count++;
}
if (n1 == M[i][j])
{
count1++;
}
if (n2 == M[i][j])
{
count2++;
}
if (n3 == M[i][j])
{
count3++;
}
if (n4 == M[i][j])
{
count4++;
}
if (n5 == M[i][j])
{
count5++;
}
if (n6 == M[i][j])
{
count6++;
}
if (n7 == M[i][j])
{
count7++;
}
}
}
cout << n0 << " ---> " <<count << endl;
cout << n1 << " ---> " <<count1 << endl;
cout << n2 << " ---> " <<count2 << endl;
cout << n3 << " ---> " <<count3 << endl;
cout << n4 << " ---> " <<count4 << endl;
cout << n5 << " ---> " <<count5 << endl;
cout << n6 << " ---> " <<count6 << endl;
cout << n7 << " ---> " <<count7 << endl;
return 0;
}
```

*Edited 3 Years Ago by Dani*: Formatting fixed