HDU 2052 Picture(玩点不一样的)
来源:互联网 发布:竞价网站数据库 编辑:程序博客网 时间:2024/06/05 22:54
水题,只是为大家提供另一种玩法
既然是输出图形嘛,平面图形,自然可以用二维数组表示。四个顶点为+,第一列和最后一列是|,第一行和最后一行为-,其他的为' '。
先全部置为空,然后将四个顶点,第一行最后一行,第一列和最后一列分别赋值,最后输出即可。
可能没有学c艹的同学不知道memset函数的用法,
作用是在一段内存块中填充某个给定的值,它是对较大的结构体或数组进行清零操作的一种最快方法#include<stdio.h>#include<string.h>int main(void) { int i, j, w, h; char ch[100][100]; while (scanf("%d %d", &w, &h) != EOF) { memset(ch, ' ', 100 * 100*sizeof(char)); ch[0][0] = '+'; ch[0][w+1] = '+'; ch[h+1][0] = '+'; ch[h+1][w+1] = '+'; for (i = 1; i <= w; i++) { ch[0][i] = '-'; ch[h+1][i] = '-'; } for (j = 1; j <= h; j++) { ch[j][0] = '|'; ch[j][w+1] = '|'; } for (i = 0; i < h+2; i++) { for (j = 0; j < w+2; j++) printf("%c", ch[i][j]); putchar('\n'); } putchar('\n'); } return 0;}
阅读全文
0 0
- HDU 2052 Picture(玩点不一样的)
- hdu 2052 picture
- Hdu 2052 - Picture
- HDU 2052 Picture
- HDU 2052 Picture
- HDU 2052 - Picture
- HDU 2052 Picture
- HDU 2052 Picture
- hdu 2052 Picture
- hdu 2052 Picture(模拟)
- HDU 2052 Picture
- HDU 2052 Picture
- HDU--2052Picture
- HDU--2052 picture
- HDU 2052 Picture
- HDU 2052 Picture
- C++ HDU 2052 Picture
- Hdu 2052 Picture
- Scala操作MySQL数据库
- java的System.getProperty()方法可以获取的值
- [题解] P1955 程序自动分析 (并查集+哈希表)
- 【Leetcode-Medium-94】Binary Tree Inorder Traversal
- sql-server基础三(select 、update、insert,delete)
- HDU 2052 Picture(玩点不一样的)
- 如何测试一支笔
- 爬虫感悟1
- 文件对比工具
- 作业.分别用while和for写出1+1/2!+1/3!.....的前20项和
- 搜索算法-顺序查找和二分查找
- python中的socketserver
- 【ubuntu】配置固定ip
- Spring DAO