My code as below for the first item:
#include "stdafx.h"
#include "vector"
#include "string"
using namespace std;
class FirstMazeTask
{
public:
string checkCorrectness(vector <string> maze)
{
bool b_overlap = false;
bool b_visited[26] = {false};
string str_RetVal("Everything is ok!");
int count = maze.size();
int n_DotCount = 0;
for(int i=0; i<count; i++)
{
string str_temp = maze[i];
int n_size_str_temp = str_temp.size();
for (int j=0; j<n_size_str_temp; j++)
{
if(str_temp[j] == '.') ++n_DotCount;
else if( str_temp[j]>='A' &&str_temp[j]<='Z')
{
if(b_visited[str_temp[j] - 'A' +1])
{
b_overlap = true;
}
else
{
b_visited[str_temp[j] - 'A' +1] = true;
}
}
}
}
if(n_DotCount<3)
{
str_RetVal = "There are less than 3 empty cells!";
return str_RetVal;
}
if(b_overlap)
{
str_RetVal = "There are at least two equal letters!";
return str_RetVal;
}
return str_RetVal;
}
};
int main(int argc, char* argv[])
{
vector <string> vs;
string s1("A.B");
vs.push_back(s1);
s1= "....." ;
vs.push_back(s1);
s1 = "B....";
vs.push_back(s1);
FirstMazeTask fm;
string srt = fm.checkCorrectness(vs);
//{"A..",
// "#.#",
// "#.B"}
// printf("Hello World!/n");
return 0;
}