POJ 1102 LC-Display
2012-08-01 15:25
253 查看
最近这个题特别手欢迎,学长说会编程语言的都会写这个题,于是我想看看我会不会。还是会的,不过上次的变形题似乎难些,待会也写了。我是按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"); } }
相关文章推荐
- UVALive5642 UVA706 HDU1332 POJ1102 LC-Display【打印图案】
- poj 1102 LC-Display显示器
- poj_1102_LC-Display(数段码模拟)
- POJ_1102_LC-Display
- poj1102 LC-Display
- poj1102 LC-Display
- poj 1102 LC-Display
- POJ 1102 - LC-Display
- poj 1102 LC-Display(模拟)
- POJ 1102 LC Display G++
- POJ 1102 LC-Display(模拟题)
- poj 1102 LC—display
- poj 1102 LC-Display
- poj1102——LC-Display
- POJ 1102 LC-Display 模拟
- OpenJudge / Poj 1102 LC-Display C++
- 1102 LC-Display
- LC-Display
- LC-Display代码
- PC110104(液晶显示屏)(LC-Display)