题目:

https://cn.vjudge.net/problem/1451310/origin

题意&思路:

纯粹模拟。

大体题意是这样的:

1、有人要在一个10-9<=x<=109,10-9<=y<=109,这么大的一张纸上去画图,而我们只需要打印输出最大为0<=x<=100,0<=y<=100范围内的图案就ok了。

2、如果s==0的话就在给出的坐标处画一个“_o_”( ASCII codes 95, 111, 95)的图案,表示a tree stump。

3、如果s>0的话,就在给出的坐标处画一个高度为s的a standing tree,这个standing tree 首先有一个root图案为:“_|_”,(ASCII codes 95, 124, 95),然后有s个“|”表示树干,最后在最高的树干上边的一个单元格中画一个“^” ASCII code 94)。

4、另一个需要注意的地方是,题目中的坐标表示为左下角为(0,0),右上角是(m-1,m-1),需要做一下下标的变换对应到数组中。

代码:

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = ;
int mp[maxn][maxn];
int n,m; void Dn(int x,int y,int id){
if(x>= && x<m && y>= && y<m){//必须是在要输出的范围内才能画上图案
mp[x][y] = id;
}
return;
} void print(){
for(int i = ; i<m+; i++){
printf("*");
}
printf("\n");
for(int i = ; i<m; i++){
for(int j = ; j<m; j++){
if(j==)printf("*");
printf("%c",mp[i][j]);
if(j==m-)
printf("*\n");
}
}
for(int i = ; i<m+; i++){
printf("*");
}
printf("\n\n");
} int main(){
while(scanf("%d%d",&m,&n)!=EOF){
for(int i = ; i<m; i++){
for(int j = ; j<m; j++){
mp[i][j] = ;
}
}
int x,y,s;
for(int kk = ; kk<n; kk++){
scanf("%d%d%d",&s,&y,&x);//注意行和列的输入位置
x = m-x-;//由题意的坐标变换到数组中的下标中
if(s==){
Dn(x,y,);//打印'o'
Dn(x,y-,);//打印'_'
Dn(x,y+,);//打印'_'
}
else if(s>){
Dn(x,y,);//打印'|'
Dn(x,y-,);//打印'_'
Dn(x,y+,);//打印'_'
for(int i=; i<=s; i++){
Dn(x-i,y,);//打印'|'
Dn(x-i,y-,);//打印'/'
Dn(x-i,y+,);//打印'\'
}
Dn(x-s-,y,);//打印'^'
}
}
print();
}
return ;
}

Gym - 101670E Forest Picture (CTU Open Contest 2017 模拟)的更多相关文章

  1. Gym - 101670H Go Northwest!(CTU Open Contest 2017 思维题+map)

    题目: Go Northwest! is a game usually played in the park main hall when occasional rainy weather disco ...

  2. Gym - 101670A Amusement Anticipation(CTU Open Contest 2017 签到题)

    题目&题意: 倒着找处于最后位置的等差数列的开头的位置. 例: 1 5 3 4 5 6 3 4 5 6是等差数列,它的开头的位置是3 PS: 读题真的很重要!!!!多组输入,上来就读错了!! ...

  3. Gym - 101670F Shooting Gallery(CTU Open Contest 2017 区间dp)

    题目&题意:(有点难读...) 给出一个数字序列,找出一个区间,当删除这个区间中的两个相同的数字后,只保留这两个数字之间的序列,然后继续删除相同的数字,问最多可以实行多少次删除操作. 例如: ...

  4. Gym - 101670G Ice cream samples(CTU Open Contest 2017 尺取法)

    题目: To encourage visitors active movement among the attractions, a circular path with ice cream stan ...

  5. Gym - 101670H Dark Ride with Monsters(CTU Open Contest 2017 贪心)

    题目: A narrow gauge train drives the visitors through the sequence of chambers in the Dark Ride attra ...

  6. Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)

    题目:链接 思路: 多画出几个情况就可以找出规律来了 Knight (当大于2的时候只要两种颜色相间出现就可以了) King(当大于等于3的时候,总可以用四种形式来补色,具体如下)  Bishop(斜 ...

  7. Gym - 101670B Pond Cascade(CTU Open Contest 2017 贪心,二分)

    题目: The cascade of water slides has been installed in the park recently and it has to be tested. The ...

  8. Gym - 101670J Punching Power(CTU Open Contest 2017 最大独立集)

    题目: The park management finally decided to install some popular boxing machines at various strategic ...

  9. CTU Open Contest 2017

    这场题很水.水题我就懒得贴了. B - Pond Cascade 优先队列维护这个水池需要多少时间 或者 直接扫一遍. #include <cstdio> #include <cst ...

随机推荐

  1. 解决Eclipse alt+/不出来提示的问题

    1. 检查windows ——preferences ——java ——editor —— content assist - advanced,在右上方有一行“select the proposal ...

  2. android developer官网不能打开怎么办

    映射网站: http://wear.techbrood.com

  3. Java 反射 —— 运行时的类型信息

    1. 反射机制的由来 RTTI 机制可以告知某个对象的确切类型,但有一个前提,该类型在编译时必须已知(编译器在编译时打开和检查 .class 文件以获取类型信息).似乎是个很宽松的限制,但假如你获取了 ...

  4. 杂项-Java:Druod Monitor

    ylbtech-杂项-Java:Druid Monitor 1.返回顶部 1. https://www.cnblogs.com/wanghuijie/p/druid_monitor.html 2. 2 ...

  5. Spring通过注解注入有参

    1.通过注解方式注入有参的构造函数 把@Autowired注解放在构造函数上方,在构造函数里写上需要注入的形参即可 2.通过XML配置文件方式定义有参构造函数

  6. E20170528-ts

    partial   adj. 部分的; 偏爱的; 偏袒的; 钟爱的; form   n. 表格; 方式; 形状,形式; 外形 annotate   vt. 注解,注释; n. 注释者; annotat ...

  7. sql server使用维护计划定时备份完整数据库、差异数据库

    我配置的是: 一个月执行一次完整备份数据库,删除三个月前备份文件.每天执行一次差异备份,删除一个月钱备份文件. 1.管理-维护计划   右键-新建维护计划 2.创建子计划 3.分别配置作业计划属性(执 ...

  8. checkbox全选和取消功能

    这是开发中常见的小功能,想当初我也曾对于attr和prop的不了解踩过坑. 前端工作中,常常会使用到select复选框,select复选框有一个属性checked,当使用js或者jquery控制这个属 ...

  9. DataGridView 动态绑定 CheckBox

    下面演示如何在 DataGridView 中动态绑定 CheckBox: public class Test { /// <summary> /// 构造器 /// </summar ...

  10. [转]T4系列文章之3:T4语法的介绍

    本文转自:http://www.cnblogs.com/damonlan/archive/2012/03/06/2382724.html 因为这段时间一直都没空,我也不知道有没有对人T4感兴趣,但不管 ...