1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <iostream>
using namespace std;
const int ROWS = 5;
const int COLS = 5;
void main()
{
char chars[ROWS][COLS] = { {'a','b', 'c', 'd', 'e'}, {'d','e','f','g','k'}, {'s','h','m','s','h'},
{ 's','f','g','k','e'}, {'s','t','s','t','n'} };
char orig;
char freqLetter;
char letter;
int i, j, max=0;
cout << "Please enter a letter " << endl;
{
cin >> letter;
}
cout << "chars" << endl;
for (int i = 0; i < ROWS; i++)
{
cout << "MATRIX" << ": " << i + 1 << endl;
for (int j = 0; j < COLS; j++)
cout << chars[i][j] << " ";
cout << "\n";
}
for (i = 0; i < COLS; i++)
{
for ( freqLetter = 0,j = 0; j < ROWS ; j++)
{
orig = chars[j][i];
if (letter == orig)
{
cout << orig << endl;
cout << j+1 << " " << i+1 << endl;
}
}
}
system("pause");
}
|