I have file which contains a lot of boards from TicTacToe 5x5.First line says how many boards this file contains (n*5x5).We check the winner in Horizontals, Verticals and Diagonals lines.Player A or B win, when has streak of minimum 3 letters (can be 4, 5) on the board. for example:ABABAAABAAAABAA ABABA AABAADraw is when Player A and B has streak of minimum 3 letters (can be 4, 5). for example:AAAAA  AAAAABAAAA  ABAAA  AABAADraw is also when nobody has streak minimum of 3.source.in - example source file2AABBABAAABAAABAABAABBAAABAAAAAAAAAABAAAAABAAAAABAAoutput.out - example correct outputA windrawAnd my code.#include <fstream>using namespace std;int main() {    int n;    char board[5][6];    ifstream source;    source.open(source.in);    ofstream output;    output.open(output.out);    source >> n;    for(int i=0; i<n; i++) {    bool A = false;    bool B = false;    bool AB = false;        // load data        for(short c=0; c<5; c++) {            for(short r=0; r<5; r++) {                source >> board[c][r];            }        }        // check Winner        //        // check Horizontal Winner        short streak = 1;        for(short y=0; y<5; y++) {            streak = 1;            for(short x=0; x<4; x++) {                if(board[y][x] == board[y][x+1]) {                    streak++;                    if(streak == 3) {                        if(board[y][x] == 'A')                            A = true;                        else                            B = true;                    }                } else                    streak = 1;            }        }        // check Vertical Winner        if(!((A == true && B == true) || (A == false && B == false))) {            for(short x=0; x<5; x++) {                streak = 1;                for(short y=0; y<4; y++) {                    if(board[y][x] == board[y+1][x]) {                        streak++;                        if(streak == 3) {                            if(board[y][x] == 'A')                                A = true;                            else                                B = true;                        }                    } else                        streak = 1;                }            }        } else            AB = true;        //check diagonal winner---------------------------------        if(AB == false) {            short streak2;            short streak3;            short streak4;            for(short j=0; j<4; j++) {                streak = 1;                streak2 = 1;                streak3 = 1;                streak4 = 1;                for(short i=0; i<5-j; i++) {                    if(board[i+j][i] == board[i+j+1][i+1]) {                        streak++;                        if(streak == 3)                            if(board[i+j][i] == 'A')                                A = true;                            else                                B = true;                    } else                        streak = 1;                    if(board[i-1][i+j] == board[i][i+1+j]) {                        streak2++;                        if(streak2 == 3)                            if(board[i-1][i+j] == 'A')                                A = true;                            else                                B = true;                    } else                        streak2 = 1;                    if(board[5-i-j][i-1] == board[5-i-1-j][i]) {                        streak3++;                        if(streak3 == 3)                            if(board[5-i-j][i-1] == 'A')                                A = true;                            else                                B = true;                        } else                            streak3 = 1;                    if(board[5-i][i+j] == board[5-1-i][i+1+j]) {                        streak4++;                        if(streak4 == 3)                            if(board[5-i][i+j] == 'A')                                A = true;                            else                                B = true;                    } else                        streak4 = 1;                }                if(A == true && B == true) {                    AB = true;                }            }        }        //---------------------------------------------        if(AB == true){            output << draw;        }        else if (A == true) {            output << A win;        } else if(B == true) {            output << B win;        }        if(i<n-1)            output << endl;    }    source.close();    output.close();    return 0;}Is it correct algorithm in my code?
TicTacToe 5x5 win or draw algorithm
c++;algorithm