POJ 1102 LC-Display
来源:互联网 发布:java多线程解压zip文件 编辑:程序博客网 时间:2024/04/20 13:24
最近这个题特别手欢迎,学长说会编程语言的都会写这个题,于是我想看看我会不会。还是会的,不过上次的变形题似乎难些,待会也写了。我是按7个结构来写的。就是8所拥有的7个部分。想来这样写还是有点复杂。不过中间那些for循环直接赋值的,没什么好思考的,还是特简单的。
代码:
#include<iostream>using namespace std;char map[300][300];void Display(int n,int c,int s){ int i,j; // printf("%d ",c); if( n!=1&&n!=4){ //上横 for( j=c+1; j<c+s+1; j++) map[0][j]='-'; } if( n!=1&&n!=0&&n!=7){ //中横 for( j=c+1; j<c+s+1; j++) map[s+1][j]='-'; } if( n!=1&&n!=4&&n!=7){ //下横 for( j=c+1; j<c+s+1; j++) map[2*s+2][j]='-'; } if( n!=1&&n!=2&&n!=3&&n!=7){ //左上竖 for( i=1; i<s+1; i++){ map[i][c]='|'; } } if( n!=5&&n!=6){ //右上竖 for( i=1; i<s+1; i++){ map[i][c+s+1]='|'; } } if( n==2||n==6||n==8||n==0){ //左下竖 for( i=s+2; i<2*s+2; i++){ map[i][c]='|'; } } if( n!=2){ //右下竖 for( i=s+2; i<2*s+2; i++){ map[i][c+s+1]='|'; } } }int main(){ int s,i,j,len,c; char str[10]; //freopen("out.txt","w",stdout); while( scanf("%d",&s)){ scanf("%s",str); if( s==0&&strcmp(str,"0")==0) break; len=strlen(str); memset(map,0,sizeof(map)); for( i=0; i<2*s+3; i++){ for( j=0; j<len*(s+3)-1; j++) map[i][j]=' '; } for( i=0; i<len; i++){ Display(str[i]-'0',(s+3)*i,s); } for( i=0; i<=2*s+2; i++) printf("%s\n",map[i]); printf("\n"); }}
- POJ 1102 LC DISPLAY
- poj 1102 LC-Display
- POJ 1102 LC-Display
- poj 1102 LC-Display
- POJ 1102 - LC-Display
- poj 1102 LC—display
- POJ 1102 LC-Display 模拟
- poj 1102 LC-Display(模拟)
- POJ 1102 LC Display 笔记
- POJ 1102 LC-Display(模拟题)
- 1102 LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- Qt 标题栏(标题、图标)设置
- 用ATL创建COM组件详细解说
- 介绍JConsole使用的文章(转载)
- 转换字串问题, 字符串+该字符的个数
- 如何理解结果导向
- POJ 1102 LC-Display
- ftp,nfs,samba基本配置
- 在开发EAS 报表的时候,锁定列的代码
- J2EE下使用AJAX(二) Prototype封装
- ubuntu下解压.zip和.rar文件
- 11 线性区的数据结构
- Struts2.0.14升级到2.3.4遇到的一些问题
- 数据库中删除语句Drop、Delete、Truncate的相同点和不同点的比较(举例说明)
- u-boot命令行接口