资源简介
C语言的科学与艺术课后习题的实训答案,
代码片段和文件信息
/*
*Coures: C Language Training
*Text:11 _12
* Name: xiang yang
*School No: 2018051604081
*/
/*
* File: checkerboard.c
* --------------------
* This program will InitCheckerboard and DisplayCheckerboard
*/
#include
#include “genlib.h“
#include “simpio.h“
/* Contants */
#define row 8
#define column 8
/* Function prtotypes */
static void DisplayCheckerboard(void);
static void InitCheckerboard(void);
static char PrintChar(int i int j);
/* Array */
static char BoardArray[row][column];
/* Main Program */
int main()
{
printf(“This program InitCherkerboard and DisplayCheckerboard\n“);
InitCheckerboard();
DisplayCheckerboard();
return 0;
}
/*
* Function: InitCheckerboard
* Usage: InitCheckerboard()
* -------------------------
* This function initializes board.
*/
static void InitCheckerboard(void)
{
int i j;
for (i = 0; i < row; i ++) {
for (j = 0; j < column; j ++) {
BoardArray[i][j] = PrintChar(i j);
}
}
}
/*
* Function: DisplayCheckerboard
* Usage: DisplayCheckerboard()
* ----------------------------
* Display checkerboard and display the current status of the Board on the screen
*/
static void DisplayCheckerboard(void)
{
int i j;
for (i = 0; i < row; i ++) {
for (j = 0; j < column; j ++) {
printf(“%c“ BoardArray[i][j]);
}
printf(“\n“);
}
}
/*
* Function: PrintChar
* Usage: PrintChar(i j)
* ------------------
* This function enter char to BoardArray[][]
*/
static char PrintChar(int i int j)
{
if ((i % 2) == 0) {
if (j % 2 == 0) return (‘ ‘);
switch (i) {
case 0: case 2: return (‘b‘);
case 4: return (‘-‘);
case 6: return (‘r‘);
}
} else {
if (j % 2 != 0) return (‘ ‘);
switch (i) {
case 1: return (‘b‘);
case 3: return (‘-‘);
case 5: case 7: return (‘r‘);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-01-05 07:53 2018051604081_xiangyang\
目录 0 2019-01-05 07:50 2018051604081_xiangyang\11_12\
文件 8496 2019-01-05 07:13 2018051604081_xiangyang\11_12\zz78_1
文件 1877 2019-01-05 07:16 2018051604081_xiangyang\11_12\11_12.c
目录 0 2019-01-05 07:51 2018051604081_xiangyang\14_12\
文件 3530 2019-01-05 04:21 2018051604081_xiangyang\14_12\14_12.c
文件 37776 2019-01-05 04:08 2018051604081_xiangyang\14_12\zz78
文件 67471 2019-01-05 04:04 2018051604081_xiangyang\2_1.PNG
文件 17911 2018-12-28 11:15 2018051604081_xiangyang\1.PNG
文件 47065 2019-01-05 03:54 2018051604081_xiangyang\2_2.PNG
文件 45000 2019-01-05 07:48 2018051604081_xiangyang\0.PNG
- 上一篇:远程桌面源码
- 下一篇:大数计算器的c语言实现
评论
共有 条评论