Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
Loading...
Searching...
No Matches
naval_battle.c File Reference

naval_battle implementation in C using only the stdio.h for Standard Input and Output. More...

#include <stdio.h>
Include dependency graph for naval_battle.c:

Functions

int validEntryLineColumn (int line, char column)
 for Standard Input Output
 
int validatePosition (int mat[10][10], int boat, int line, int column, char guide)
 Function validatePosition Responsible for checking if the position can receive the boat.
 
int canShoot (int mat[10][10], int line, int column)
 Function canShoot Responsible to verify that it is a valid position to shoot.
 
void positionBoat (int mat[10][10], int boat)
 Function positionBoat Responsible for placing the boats on the board, according to the size.
 
void printMessage (char *msg)
 Function printMessage Responsible for printing the auxiliary message.
 
void printMessageScore (int pts1, int pts2)
 Function printMessageScore Responsible for printing the score messages.
 
char printTable (int logic, int stage)
 Function printTable Responsible for printing the board.
 
void printsTray (int mat[10][10], int stage)
 Function printsTray Responsible for printing the visual board for the user.
 
void shoot (int mat[10][10], int line, int column)
 Function shoot Responsible for saying if he hit a boat.
 
int calculateScore (int mat[10][10], int line, int column)
 Function calculateScore Responsible for calculating the score obtained during the game.
 
void printPositioning (int Player, int boat, int nm)
 Function printPositioning Responsible for printing messages for positioning boats on the board; of player 1 and 2.
 
int main ()
 Main function.
 

Detailed Description

naval_battle implementation in C using only the stdio.h for Standard Input and Output.

Author
Carlos Rafael
Herick Lima

Naval battle is a game, to be played by two people. It consists of knocking down the enemy ship, through shots , when hit the ship is revealed with the respective number of its size. Example: size 3 = 3 3 3 on the board. To play - boats over size 1, need direction; V -> vertical and H -> horizontal. Example Input 1 A H -> line 1, column A, direction H (Horizontal).

Function Documentation

◆ calculateScore()

int calculateScore ( int  mat[10][10],
int  line,
int  column 
)

Function calculateScore Responsible for calculating the score obtained during the game.

Parameters
matboard
linematrix row
columnmatrix column
Returns
resulting score
443{
444 int c = 0, b = 0, e = 0, d = 0;
445
446 if (mat[line][column] == 10)
447 {
448 mat[line][column] = 50;
449 return 2;
450 }
451
452 else if (mat[line][column] == 20)
453 {
454 if (mat[line + 1][column] == 20)
455 {
456 b = 1;
457 }
458
459 if (mat[line - 1][column] == 20)
460 {
461 c = 1;
462 }
463
464 if (mat[line][column + 1] == 20)
465 {
466 d = 1;
467 }
468
469 if (mat[line][column - 1] == 20)
470 {
471 e = 1;
472 }
473
474 if (b == 1)
475 {
476 if (mat[line + 1][column] == 20)
477 {
478 mat[line][column] = 50;
479 mat[line + 1][column] = 50;
480 return 4;
481 }
482 else
483 {
484 return 0;
485 }
486 }
487
488 if (c == 1)
489 {
490 if (mat[line - 1][column] == 20)
491 {
492 mat[line][column] = 50;
493 mat[line - 1][column] = 50;
494 return 4;
495 }
496 else
497 {
498 return 0;
499 }
500 }
501
502 if (d == 1)
503 {
504 if (mat[line][column + 1] == 20)
505 {
506 mat[line][column] = 50;
507 mat[line][column + 1] = 50;
508 return 4;
509 }
510 else
511 {
512 return 0;
513 }
514 }
515
516 if (e == 1)
517 {
518 if (mat[line][column - 1] == 20)
519 {
520 mat[line][column] = 50;
521 mat[line][column - 1] = 50;
522 return 4;
523 }
524 else
525 {
526 return 0;
527 }
528 }
529 }
530
531 else if (mat[line][column] == 30)
532 {
533 if (mat[line + 1][column] == 30)
534 {
535 b = 1;
536 }
537
538 if (mat[line - 1][column] == 30)
539 {
540 c = 1;
541 }
542 if (mat[line][column + 1] == 30)
543 {
544 d = 1;
545 }
546
547 if (mat[line][column - 1] == 30)
548 {
549 e = 1;
550 }
551
552 if (b == 1 && c == 1)
553 {
554 if (mat[line + 1][column] == 30 && mat[line - 1][column] == 30)
555 {
556 mat[line][column] = 50;
557 mat[line + 1][column] = 50;
558 mat[line - 1][column] = 50;
559 return 7;
560 }
561 else
562 {
563 return 0;
564 }
565 }
566
567 else if (d == 1 && e == 1)
568 {
569 if (mat[line][column + 1] == 30 && mat[line][column - 1] == 30)
570 {
571 mat[line][column] = 50;
572 mat[line][column - 1] = 50;
573 mat[line][column + 1] = 50;
574 return 7;
575 }
576 else
577 {
578 return 0;
579 }
580 }
581
582 else if (d == 1)
583 {
584 if (mat[line][column + 1] == 30 && mat[line][column + 2] == 30)
585 {
586 mat[line][column] = 50;
587 mat[line][column + 1] = 50;
588 mat[line][column + 2] = 50;
589 return 7;
590 }
591 else
592 {
593 return 0;
594 }
595 }
596
597 else if (e == 1)
598 {
599 if (mat[line][column - 1] == 30 && mat[line][column - 2] == 30)
600 {
601 mat[line][column] = 50;
602 mat[line][column - 1] = 50;
603 mat[line][column - 2] = 50;
604 return 7;
605 }
606 else
607 {
608 return 0;
609 }
610 }
611
612 else if (c == 1)
613 {
614 if (mat[line - 1][column] == 30 && mat[line - 2][column] == 30)
615 {
616 mat[line][column] = 50;
617 mat[line - 1][column] = 50;
618 mat[line - 2][column] = 50;
619 return 7;
620 }
621 else
622 {
623 return 0;
624 }
625 }
626
627 else if (b == 1)
628 {
629 if (mat[line + 1][column] == 30 && mat[line + 2][column] == 30)
630 {
631 mat[line][column] = 50;
632 mat[line + 1][column] = 50;
633 mat[line + 2][column] = 50;
634 return 7;
635 }
636 else
637 {
638 return 0;
639 }
640 }
641 }
642 return 0;
643}

◆ canShoot()

int canShoot ( int  mat[10][10],
int  line,
int  column 
)

Function canShoot Responsible to verify that it is a valid position to shoot.

Parameters
matboard
linematrix row
columnmatrix column
Returns
if the position is valid for shooting
108{
109 if (mat[line][column] == -2 || mat[line][column] == 10 ||
110 mat[line][column] == 20 || mat[line][column] == 30 ||
111 mat[line][column] == 50)
112 {
113 return 0;
114 }
115
116 return 1;
117}

◆ main()

int main ( void  )

Main function.

Returns
0 on exit

the one with the most points wins, or the one who knocks down all boats first.

814{
815 int Player1[10][10];
816 int Player2[10][10];
817 int plays = 1;
818 int pts1 = 0, pts2 = 0, a1 = 0, a2 = 0;
819 int line, col = 0, lin = 0;
820 char column;
821
822 // filling matrix with 0
823 for (int i = 0; i < 10; i++)
824 {
825 for (int j = 0; j < 10; j++)
826 {
827 Player1[i][j] = 0;
828 Player2[i][j] = 0;
829 }
830 }
831
832 // positioning boats
833 for (int i = 1; i <= 2; i++)
834 {
835 for (int j = 1; j <= 6; j++)
836 {
837 if (i == 1)
838 {
839 printPositioning(i, 1, j);
840 printsTray(Player1, 0);
841 positionBoat(Player1, 1);
842 }
843 else if (i == 2)
844 {
845 printPositioning(i, 1, j);
846 printsTray(Player2, 0);
847 positionBoat(Player2, 1);
848 }
849 }
850 for (int j = 1; j <= 4; j++)
851 {
852 if (i == 1)
853 {
854 printPositioning(i, 2, j);
855 printsTray(Player1, 0);
856 positionBoat(Player1, 2);
857 }
858 else if (i == 2)
859 {
860 printPositioning(i, 2, j);
861 printsTray(Player2, 0);
862 positionBoat(Player2, 2);
863 }
864 }
865 for (int j = 1; j <= 2; j++)
866 {
867 if (i == 1)
868 {
869 printPositioning(i, 3, j);
870 printsTray(Player1, 0);
871 positionBoat(Player1, 3);
872 }
873 else if (i == 2)
874 {
875 printPositioning(i, 3, j);
876 printsTray(Player2, 0);
877 positionBoat(Player2, 3);
878 }
879 }
880 }
881
882 // starting the game
883 while (plays <= 40)
884 {
885 if (plays % 2 != 0)
886 {
887 printMessageScore(pts1, pts2);
888 printMessage("Player 1's turn");
889 printsTray(Player2, 1);
890 scanf("%d %c", &line, &column);
891
892 while (validEntryLineColumn(line, column) != 1 ||
893 canShoot(Player2, line - 1, column - 65) != 1)
894 {
895 line = 0;
896 column = 'a';
897 printf("Position unavailable!\n");
898 scanf("%d %c", &line, &column);
899 }
900 lin = line - 1;
901 col = column - 65;
902 shoot(Player2, lin, col);
903 a1 = pts1;
904 pts1 += calculateScore(Player2, lin, col);
905
906 if (a1 != pts1)
907 {
908 printMessage("Player 1 DROPPED A BOAT!");
909 }
910 }
911 else
912 {
913 printMessageScore(pts1, pts2);
914 printMessage("Player 2's turn");
915 printsTray(Player1, 1);
916 scanf("%d %c", &line, &column);
917
918 while (validEntryLineColumn(line, column) != 1 ||
919 canShoot(Player1, line - 1, column - 65) != 1)
920 {
921 printf("Position unavailable!\n");
922 scanf("%d %c", &line, &column);
923 }
924 lin = line - 1;
925 col = column - 65;
926 shoot(Player1, lin, col);
927 a2 = pts2;
928 pts2 += calculateScore(Player1, lin, col);
929
930 if (a2 != pts2)
931 {
932 printMessage("Player 2 DROPPED A BOAT!");
933 }
934 }
935
936 plays++;
937 }
938 /**
939 * the one with the most points wins, or the one who knocks down all boats
940 * first.
941 */
942 printMessage("END GAME\n");
943 printMessageScore(pts1, pts2);
944
945 return 0;
946}
void shoot(int mat[10][10], int line, int column)
Function shoot Responsible for saying if he hit a boat.
Definition: naval_battle.c:411
void printMessageScore(int pts1, int pts2)
Function printMessageScore Responsible for printing the score messages.
Definition: naval_battle.c:280
void positionBoat(int mat[10][10], int boat)
Function positionBoat Responsible for placing the boats on the board, according to the size.
Definition: naval_battle.c:124
void printMessage(char *msg)
Function printMessage Responsible for printing the auxiliary message.
Definition: naval_battle.c:266
int canShoot(int mat[10][10], int line, int column)
Function canShoot Responsible to verify that it is a valid position to shoot.
Definition: naval_battle.c:107
void printPositioning(int Player, int boat, int nm)
Function printPositioning Responsible for printing messages for positioning boats on the board; of pl...
Definition: naval_battle.c:652
int validEntryLineColumn(int line, char column)
for Standard Input Output
Definition: naval_battle.c:25
int calculateScore(int mat[10][10], int line, int column)
Function calculateScore Responsible for calculating the score obtained during the game.
Definition: naval_battle.c:442
void printsTray(int mat[10][10], int stage)
Function printsTray Responsible for printing the visual board for the user.
Definition: naval_battle.c:355
Here is the call graph for this function:

◆ positionBoat()

void positionBoat ( int  mat[10][10],
int  boat 
)

Function positionBoat Responsible for placing the boats on the board, according to the size.

Parameters
matboard
boatboat
125{
126 int line, j;
127 char column, guide;
128
129 if (boat == 1)
130 {
131 scanf("%d %c", &line, &column);
132
133 while (validEntryLineColumn(line, column) != 1 ||
134 validatePosition(mat, boat, (line - 1), (column - 65), 'H') != 1)
135 {
136 printf("Position unavailable!\n");
137 scanf("%d %c", &line, &column);
138 }
139 }
140
141 else
142 {
143 scanf("%d %c %c", &line, &column, &guide);
144
145 while (validEntryLineColumn(line, column) == 0 ||
146 validatePosition(mat, boat, (line - 1), (column - 65), guide) ==
147 0)
148 {
149 printf("Position unavailable!\n");
150 scanf("%d %c %c", &line, &column, &guide);
151 }
152 }
153
154 int aux = column - 'A';
155 line -= 1;
156
157 if (boat == 1)
158 {
159 for (j = aux; j < (aux + boat); j++)
160 {
161 mat[line][j] = boat;
162 }
163
164 for (int a = line - 1; a < (line + boat + 1); a++)
165 {
166 for (int b = aux - 1; b < (aux + boat + 1); b++)
167 {
168 if (a >= 0 && a <= 9 && b >= 0 && b <= 9)
169 {
170 if (mat[a][b] != boat)
171 {
172 mat[a][b] = -1;
173 }
174 }
175 }
176 }
177 }
178
179 if (guide == 'H')
180 {
181 for (j = aux; j < (aux + boat); j++)
182 {
183 mat[line][j] = boat;
184 }
185 if (boat == 3)
186 {
187 for (int a = line - 1; a < (line + boat - 1); a++)
188 {
189 for (int b = aux - 1; b < (aux + boat + 1); b++)
190 {
191 if (a >= 0 && a <= 9 && b >= 0 && b <= 9)
192 {
193 if (mat[a][b] != boat)
194 {
195 mat[a][b] = -1;
196 }
197 }
198 }
199 }
200 }
201
202 else
203 {
204 for (int a = line - 1; a < (line + boat); a++)
205 {
206 for (int b = aux - 1; b < (aux + boat + 1); b++)
207 {
208 if (a >= 0 && a <= 9 && b >= 0 && b <= 9)
209 {
210 if (mat[a][b] != boat)
211 {
212 mat[a][b] = -1;
213 }
214 }
215 }
216 }
217 }
218 }
219
220 if (guide == 'V')
221 {
222 for (j = line; j < (line + boat); j++)
223 {
224 mat[j][aux] = boat;
225 }
226 if (boat == 3)
227 {
228 for (int a = line - 1; a < (line + boat + 1); a++)
229 {
230 for (int b = aux - 1; b < (aux + boat - 1); b++)
231 {
232 if (a >= 0 && a <= 9 && b >= 0 && b <= 9)
233 {
234 if (mat[a][b] != boat)
235 {
236 mat[a][b] = -1;
237 }
238 }
239 }
240 }
241 }
242
243 else
244 {
245 for (int a = line - 1; a < (line + boat + 1); a++)
246 {
247 for (int b = aux - 1; b < (aux + boat); b++)
248 {
249 if (a >= 0 && a <= 9 && b >= 0 && b <= 9)
250 {
251 if (mat[a][b] != boat)
252 {
253 mat[a][b] = -1;
254 }
255 }
256 }
257 }
258 }
259 }
260}
int validatePosition(int mat[10][10], int boat, int line, int column, char guide)
Function validatePosition Responsible for checking if the position can receive the boat.
Definition: naval_battle.c:43
Here is the call graph for this function:

◆ printMessage()

void printMessage ( char *  msg)

Function printMessage Responsible for printing the auxiliary message.

Parameters
msgmsg with board
267{
268 printf("************************\n");
269 printf("*\n");
270 printf("* %s\n", msg);
271 printf("*\n");
272 printf("************************\n");
273}

◆ printMessageScore()

void printMessageScore ( int  pts1,
int  pts2 
)

Function printMessageScore Responsible for printing the score messages.

Parameters
pts1player 1 score
pts2player 2 score
281{
282 printf("************************\n");
283 printf("*\n");
284 printf("* Player'S SCORE 1: %02d\n", pts1);
285 printf("* Player'S SCORE 2: %02d\n", pts2);
286 printf("*\n");
287 printf("************************\n");
288}

◆ printPositioning()

void printPositioning ( int  Player,
int  boat,
int  nm 
)

Function printPositioning Responsible for printing messages for positioning boats on the board; of player 1 and 2.

Parameters
Playernumber representing the Player
boatnumber that represents the boat
nmwhich message to print
653{
654 if (Player == 1)
655 {
656 char msg1[60] = "Player 1 - Position the size boat 1 (1/6)";
657 char msg2[60] = "Player 1 - Position the size boat 1 (2/6)";
658 char msg3[60] = "Player 1 - Position the size boat 1 (3/6)";
659 char msg4[60] = "Player 1 - Position the size boat 1 (4/6)";
660 char msg5[60] = "Player 1 - Position the size boat 1 (5/6)";
661 char msg6[60] = "Player 1 - Position the size boat 1 (6/6)";
662
663 char msg7[60] = "Player 1 - Position the size boat 2 (1/4)";
664 char msg8[60] = "Player 1 - Position the size boat 2 (2/4)";
665 char msg9[60] = "Player 1 - Position the size boat 2 (3/4)";
666 char msg10[60] = "Player 1 - Position the size boat 2 (4/4)";
667
668 char msg11[60] = "Player 1 - Position the size boat 3 (1/2)";
669 char msg12[60] = "Player 1 - Position the size boat 3 (2/2)";
670
671 if (boat == 1)
672 {
673 if (nm == 1)
674 {
675 printMessage(msg1);
676 }
677 else if (nm == 2)
678 {
679 printMessage(msg2);
680 }
681 else if (nm == 3)
682 {
683 printMessage(msg3);
684 }
685
686 else if (nm == 4)
687 {
688 printMessage(msg4);
689 }
690
691 else if (nm == 5)
692 {
693 printMessage(msg5);
694 }
695
696 else if (nm == 6)
697 {
698 printMessage(msg6);
699 }
700 }
701 else if (boat == 2)
702 {
703 if (nm == 1)
704 {
705 printMessage(msg7);
706 }
707 else if (nm == 2)
708 {
709 printMessage(msg8);
710 }
711 else if (nm == 3)
712 {
713 printMessage(msg9);
714 }
715 else if (nm == 4)
716 {
717 printMessage(msg10);
718 }
719 }
720 else if (boat == 3)
721 {
722 if (nm == 1)
723 {
724 printMessage(msg11);
725 }
726 if (nm == 2)
727 {
728 printMessage(msg12);
729 }
730 }
731 }
732
733 if (Player == 2)
734 {
735 char msg1[60] = "Player 2 - Position the size boat 1 (1/6)";
736 char msg2[60] = "Player 2 - Position the size boat 1 (2/6)";
737 char msg3[60] = "Player 2 - Position the size boat 1 (3/6)";
738 char msg4[60] = "Player 2 - Position the size boat 1 (4/6)";
739 char msg5[60] = "Player 2 - Position the size boat 1 (5/6)";
740 char msg6[60] = "Player 2 - Position the size boat 1 (6/6)";
741
742 char msg7[60] = "Player 2 - Position the size boat 2 (1/4)";
743 char msg8[60] = "Player 2 - Position the size boat 2 (2/4)";
744 char msg9[60] = "Player 2 - Position the size boat 2 (3/4)";
745 char msg10[60] = "Player 2 - Position the size boat 2 (4/4)";
746
747 char msg11[60] = "Player 2 - Position the size boat 3 (1/2)";
748 char msg12[60] = "Player 2 - Position the size boat 3 (2/2)";
749
750 if (boat == 1)
751 {
752 if (nm == 1)
753 {
754 printMessage(msg1);
755 }
756 else if (nm == 2)
757 {
758 printMessage(msg2);
759 }
760 else if (nm == 3)
761 {
762 printMessage(msg3);
763 }
764 else if (nm == 4)
765 {
766 printMessage(msg4);
767 }
768 else if (nm == 5)
769 {
770 printMessage(msg5);
771 }
772 else if (nm == 6)
773 {
774 printMessage(msg6);
775 }
776 }
777 else if (boat == 2)
778 {
779 if (nm == 1)
780 {
781 printMessage(msg7);
782 }
783 else if (nm == 2)
784 {
785 printMessage(msg8);
786 }
787 else if (nm == 3)
788 {
789 printMessage(msg9);
790 }
791 else if (nm == 4)
792 {
793 printMessage(msg10);
794 }
795 }
796 else if (boat == 3)
797 {
798 if (nm == 1)
799 {
800 printMessage(msg11);
801 }
802 else if (nm == 2)
803 {
804 printMessage(msg12);
805 }
806 }
807 }
808}
Here is the call graph for this function:

◆ printsTray()

void printsTray ( int  mat[10][10],
int  stage 
)

Function printsTray Responsible for printing the visual board for the user.

Parameters
matMatrix
stagegame step
356{
357 int logic;
358 char imp;
359
360 printf(" ");
361 for (int i = 65; i < 75; i++)
362 {
363 printf("%c", i);
364 if (i < 74)
365 {
366 printf(" ");
367 }
368 }
369 printf("\n");
370
371 for (int i = 0; i < 12; i++)
372 {
373 if (i > 0 && i < 11)
374 {
375 printf("%02d ", i);
376 }
377
378 else
379 {
380 printf(" ");
381 }
382
383 for (int j = 0; j < 12; j++)
384 {
385 if ((i > 0 && i < 11) && (j > 0 && j < 11))
386 {
387 logic = mat[i - 1][j - 1];
388 imp = printTable(logic, stage);
389 printf("%c", imp);
390 }
391 else
392 {
393 printf("#");
394 }
395
396 if (j < 11)
397 {
398 printf(" ");
399 }
400 }
401 printf("\n");
402 }
403}
char printTable(int logic, int stage)
Function printTable Responsible for printing the board.
Definition: naval_battle.c:296
Here is the call graph for this function:

◆ printTable()

char printTable ( int  logic,
int  stage 
)

Function printTable Responsible for printing the board.

Parameters
logicreturn of the logical matrix
stagegame step
Returns
char for visual matrix
297{
298 if (stage == 0)
299 {
300 if (logic == 0)
301 {
302 return '.';
303 }
304
305 else if (logic == -1)
306 {
307 return '*';
308 }
309
310 else if (logic == 1)
311 {
312 return '1';
313 }
314
315 else if (logic == 2)
316 {
317 return '2';
318 }
319
320 else
321 {
322 return '3';
323 }
324 }
325
326 else
327 {
328 if (logic == 0 || logic == -1 || logic == 1 || logic == 2 || logic == 3)
329 {
330 return '.';
331 }
332
333 else if (logic == -2)
334 {
335 return 'x';
336 }
337
338 else if (logic == 10 || logic == 20 || logic == 30)
339 {
340 return 'N';
341 }
342
343 else
344 {
345 return 'A';
346 }
347 }
348}

◆ shoot()

void shoot ( int  mat[10][10],
int  line,
int  column 
)

Function shoot Responsible for saying if he hit a boat.

Parameters
matboard
linematrix row
columnmatrix column
412{
413 if (mat[line][column] == 0 || mat[line][column] == -1)
414 {
415 mat[line][column] = -2;
416 }
417
418 else if (mat[line][column] == 1)
419 {
420 mat[line][column] = 10;
421 }
422
423 else if (mat[line][column] == 2)
424 {
425 mat[line][column] = 20;
426 }
427
428 else if (mat[line][column] == 3)
429 {
430 mat[line][column] = 30;
431 }
432}

◆ validatePosition()

int validatePosition ( int  mat[10][10],
int  boat,
int  line,
int  column,
char  guide 
)

Function validatePosition Responsible for checking if the position can receive the boat.

Parameters
matboard
boatboat
linematrix row
columnmatrix column
Returns
if the position is valid
45{
46 int cont = 0;
47 int i, j;
48
49 if (line < 0 || line > 9 || column < 0 || column > 9 ||
50 (guide != 'H' && guide != 'V') || boat < 1 || boat > 3)
51 {
52 return 0;
53 }
54
55 if (guide == 'H')
56 {
57 if ((10 - column) < boat)
58 {
59 return 0;
60 }
61 else
62 {
63 for (j = column; j < (column + boat); j++)
64 {
65 if (mat[line][j] == 0)
66 {
67 cont++;
68 }
69 }
70 }
71 }
72
73 if (guide == 'V')
74 {
75 if ((10 - line) < boat)
76 {
77 return 0;
78 }
79
80 else
81 {
82 for (i = line; i < (line + boat); i++)
83 {
84 if (mat[i][column] == 0)
85 {
86 cont++;
87 }
88 }
89 }
90 }
91
92 if (cont == boat)
93 {
94 return 1;
95 }
96 return 0;
97}

◆ validEntryLineColumn()

int validEntryLineColumn ( int  line,
char  column 
)

for Standard Input Output

Function validEntryLineColumn Responsible for validating entries, for positioning boats

Parameters
linematrix row
columnmatrix column
Returns
if the row and column are valid
26{
27 if ((line >= 1 && line <= 10) && (column >= 65 && column <= 74))
28 {
29 return 1;
30 }
31
32 return 0;
33}