UVa 11074
来源:互联网 发布:microsoft c 软件下载 编辑:程序博客网 时间:2024/06/05 07:32
题目:绘制方形格子,边界用'*',空白百'.',已知边界宽度,空白的宽度和空白的个数,绘图。
分析:模拟。直接按照题目绘图即可,关键是计算坐标。
总的大小:S*N + T*(N+1);
空白起点:S*i + T*(i+1),S*j + T*(j+1);
说明:(⊙v⊙)。
#include <stdio.h>#include <stdlib.h>#include <string.h>char grid[888][888];int main(){int S, T, N , cases = 1;while (~scanf("%d%d%d",&S,&T,&N) && S+T+N) {printf("Case %d:\n",cases ++);int total = S*N + T*(N+1);for (int i = 0; i < total; ++ i) {for (int j = 0; j < total; ++ j) {grid[i][j] = '*';}grid[i][total] = 0;}for (int i = 0; i < N; ++ i) {for (int j = 0; j < N; ++ j) {int sp = S*i + T*(i+1);int sq = S*j + T*(j+1);for (int p = 0; p < S; ++ p) {for (int q = 0; q < S; ++ q) {grid[sp+p][sq+q] = '.';}}}}for (int i = 0; i < total; ++ i) {puts(grid[i]);}puts("");} return 0;}
阅读全文
0 0
- UVa 11074
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- [Linux][入门系列]Linux&Mac网络工具全解(持续更新)
- JS中的5种数组方法
- 快速幂
- JavaScript中&&和||的用法
- 关于移动位置最简单的方法
- UVa 11074
- ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe
- android休眠唤醒流程:
- GCC内嵌汇编一些限制字符串
- 将excel中的内容导入mysql中
- 用Intillij IDEA实现MyBatis逆向工程
- Codeforces Round #426 (Div. 2) C The Meaningless Game
- jar、war、ear包的作用和区别
- Eclipse将引用了第三方jar包的Java项目打包成jar文件的两种方法