In the game of chess, the bishop can attack other pieces diagonally.                 
For this assignment, you will write a program called bishops.c
.
It will read a description of a chessboard (not necessarily eight-by-eight)
that contains a number of bishops. The program will tell you
which bishops are attacking other bishops.
                
Here’s an example of a data file:                 
3x4 . . C . . . . . A . . B
The first line is an integer indicating the height of the board, an “x”, and an integer indicating the width of the board. After that follows:
After reading the data file, the program should indicate which
bishops are attacking each other, like this: “A attacks B
”.
                
To avoid redundancy, don’t display both “B attacks G
” and
“G attacks B
”. Only display “B attacks G
”, since 'B'<'G'
.
                
The output lines may be in any order. We will sort
your output
before looking at it.
                
Here are several sample runs, where “%
” is my prompt:
                
% c11 -Wall bishops.c % cat bishop-data1 3x4 . . C . . . . . A . . B % ./a.out bishop-data1 A attacks C % cat bishop-data1-ugly 3x4 . . C.. . . . A.. B % ./a.out bishop-data1-ugly A attacks C % cat bishop-data2 8x8 . . . . . . . . . . . . . . . . . B . C . . . . . . . . D . . . . . . . . E . . . . . A . . . G . . . . . . F . . . . . . . . . % ./a.out bishop-data2 C attacks D C attacks E D attacks E F attacks G % cat bishop-data3 3x3 Z G . . . H . D Q % ./a.out bishop-data3 G attacks H D attacks H Q attacks Z
If you encounter “STACK FRAME LINK OVERFLOW”, then try this:
export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a
A
”.
argv[0]
.
argv[0]
and the filename.
'$'
is encountered,
etc.) then print a message to standard error, including argv[0]
and the filename.
#defines
are fine).
char
constants for char
values, not int
ASCII values:
'A'
, not 65
.
Use web checkin, or:                 
~cs157/bin/checkin HW3 bishops.c
Turn in someone else’s work.                 
User: Guest