Codeforces 435C Cardiogram
来源:互联网 发布:js创建一个数组 编辑:程序博客网 时间:2024/06/03 21:52
题意:
给你n个数a[i],要你模拟出一座每列高a[i]的山。
思路:
题目说了所有的a[i]和不会超过1000,那么这就简单了,开个3000*3000的数组(因为这些山的高度是有落差的),然后从r=1500行开始模拟就可以啦。注意这里空白的地方要输出空格(坑)。
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int MAX=1005;int n,a[MAX];char mp[MAX*3][MAX*3];int main(){scanf("%d",&n);int r=1500,j=1,Max=1500,Min=1500;memset(mp,' ',sizeof(mp));for(int i=1;i<=n;i++){scanf("%d",&a[i]);if(i%2){int k;for(k=r;k<r+a[i];k++){mp[k][j++]='/';}r=k-1;}else{int k;for(k=r;k>r-a[i];k--){mp[k][j++]='\\';}r=k+1;}Max=max(Max,r);Min=min(Min,r);}for(int i=Max;i>=Min;i--){for(int c=1;c<j;c++){printf("%c",mp[i][c]);}printf("\n");}return 0;}
0 0
- Codeforces 435C Cardiogram
- Codeforces 435C. Cardiogram
- CodeForces 435C Cardiogram
- Codeforces 435C Cardiogram
- Cardiogram CodeForces
- Codeforces Round #249 (Div. 2)C. Cardiogram
- C. Cardiogram
- Codeforces Round #249 (Div. 2)453C Cardiogram(模拟)
- cf435C Cardiogram
- Codeforces-340-C(c++)
- Codeforces-507-C(c++)
- CodeForces 731C C
- CodeForces-612C C
- CODEFORCES 265C CODEFORCES, 265C
- codeforces #78 div2 C
- Codeforces 117C Cycle
- CodeForces 209C
- CodeForces 156C Cipher
- 一、搭建移动应用服务器
- Linux Samba 服务器配置
- HDU 3368 Reversi (简单dfs)
- hdu5754各种博弈
- SpringMVC接收复杂集合参数
- Codeforces 435C Cardiogram
- 二叉树的最长/最短路径
- Spring Aop的理解和概念
- dom4j CURD
- AsyncTask和Handler对比
- xml基础概念
- Android加载动画系列—— CircularJumpLoadingAnim
- Android应用程序的启动过程源码解析—点击图标启动过程
- HDOJ 4004 The Frog's Games