打印图形
来源:互联网 发布:python 图片处理 编辑:程序博客网 时间:2024/05/01 16:11
char g_print_array[20][20] = {{0}};struct my_point{ int i; int j;};- (int)print_array_init:(char)c{ int i = 0; int j = 0; for (i = 0; i < 20; i++) { for (j = 0; j < 20; j++) { g_print_array[i][j] = c; } } return 0;}- (int)print_array_show{ int i = 0; int j = 0; for (i = 0; i < 20; i++) { for (j = 0; j < 20; j++) { printf("%c", g_print_array[i][j]); } printf("\n"); } return 0;}- (int)print_array_assign_with:(struct my_point)point{ g_print_array[point.i][point.j] = '-'; return 0;}- (int)print_point_to_point:(struct my_point)from to:(struct my_point)to{ int line_step = to.i - from.i; int col_step = to.j - from.j; int cur_line = from.i; int cur_col = from.j; if (line_step > 0) { line_step = 1; } else if (line_step < 0) { line_step = -1; } else { line_step = 0; } if (col_step > 0) { col_step = 1; } else if (col_step < 0) { col_step = -1; } else { col_step = 0; } for (int step = 0; step < 20; step++) { g_print_array[cur_line][cur_col] = '.'; if (cur_line != to.i) { cur_line = cur_line + line_step; } if (cur_col != to.j) { cur_col = cur_col + col_step; } if ((cur_line == to.i)&&(cur_col == to.j)) break; } return 0;}
调用
struct my_point from_point = {19,19}; struct my_point to_point = {3,7}; struct my_point next_from_point = {3,13}; struct my_point next_to_point = {27,13}; [self print_array_init:' ']; [self print_point_to_point:from_point to:to_point]; [self print_point_to_point:next_from_point to:next_to_point]; //[self print_array_assign_with:point]; [self print_array_show];
0 0
- 打印图形
- 打印图形
- 打印图形
- 打印图形
- 打印图形
- 打印图形
- 打印图形
- 打印图形
- 打印图形
- 图形打印
- 打印图形
- 打印***图形
- 打印图形
- 打印图形
- 打印图形
- 打印图形
- 打印图形
- 图形打印
- Java字符串的10大热点问题盘点
- what is the difference between definition and declaration in c
- 【BZOJ】【P1101】【POI2007】【Zap】【题解】【莫比乌斯反演】
- js格式化xml字符串
- java格式化xml字符串
- 打印图形
- 关于JAVA类集学习总结
- spring工具类HtmlUtils
- Android开发之旅:环境搭建及HelloWorld
- PAT 1033. To Fill or Not to Fill (贪心)
- AVL平衡树的插入例程
- 《Java并发编程实战》第十一章 性能与可伸缩性 读书笔记
- OpenGL 矩阵变换相关链接
- u-boot学习(二):u-boot简要分析