POJ1102-模拟
来源:互联网 发布:手机淘宝掌柜热卖截图 编辑:程序博客网 时间:2024/04/28 07:21
题目:题目链接
题意:给出一个数字,按照要求的宽度大小输出LD式的数字表示
分析:模拟,把n是1的情况先一个数字一个数字搞出来。然后再根据n放大。蛋疼的模拟......
代码:
#include <iostream>#include <cstdio>#include <string>#include <string.h>#include <map>#include <vector>#include <cstdlib>#include <algorithm>#include <cmath>#include <queue>#include <set>#include <stack>#include <functional>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cassert>#include <bitset>#include <stack>#include <ctime>#include <list>#define INF 0x7fffffff#define max3(a,b,c) (max(a,b)>c?max(a,b):c)#define min3(a,b,c) (min(a,b)<c?min(a,b):c)#define mem(a,b) memset(a,b,sizeof(a))using namespace std;int QuickMod(int a,int b,int n){ int r = 1; while(b) { if(b&1) r = (r*a)%n; a = (a*a)%n; b >>= 1; } return r;}char nums[10][5][3] ={ {{' ', '-', ' '}, {'|', ' ', '|'}, {' ', ' ', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}}, {{' ', ' ', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}}, {{' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}, {'|', ' ', ' '}, {' ', '-', ' '}}, {{' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}}, {{' ', ' ', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}}, {{' ', '-', ' '}, {'|', ' ', ' '}, {' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}}, {{' ', '-', ' '}, {'|', ' ', ' '}, {' ', '-', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}}, {{' ', '-', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}}, {{' ', '-', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}}, {{' ', '-', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}}};int main(){ int i, x, jj, kk; int n, m, digits[20]; while(scanf("%d%d", &n, &m) == 2) { if(!n && !m) break; i = 0; if(m == 0) //注意0 { x = 1; digits[0] = 0; } else { //转为单个数字放在数组里 while(m > 0) { digits[i] = m % 10; m = m / 10; i++; } x = i; } for(int j = 0; j < 2*n+3; ++j) { jj = j; if(j > 0 && j <= n) jj = 1; if(j == n+1) jj = 2; if(j > n+1 && j < 2*n+3-1) jj = 3; if(j == 2*n+3-1) jj = 4; for(i = x-1; i >= 0; --i) { for(int k = 0; k < n+2; ++k) { kk = 0; if(k > 0 && k < n+1) kk = 1; if(k == n+1) kk = 2; printf("%c", nums[digits[i]][jj][kk]); } printf(" "); //数字之间要有空格 } printf("\n"); } printf("\n"); //输出一个数据后要有空行 } return 0;}
蛋疼.....
- POJ1102-模拟
- POJ1102
- poj1102
- poj1102解题报告
- poj1102 LC-Display
- LC-Display POJ1102
- poj1102 LC-Display
- poj1102——LC-Display
- poj1102数字打印,七段数字码
- POJ1102 LC-Display【打印图案】
- poj1102+每个数字有七笔画每行扫描+注意细节每个样例后要有两个回车
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- Java的synchronized关键字:同步机制总结(转载)
- 2014阿里巴巴面试题哈尔滨
- 大规模分布式存储系统
- VIM 配置和學習
- 解析数据库和操作系统中锁的几个问题
- POJ1102-模拟
- 阻止jquery datepicker控件在移动设备上被点击时弹出输入键盘
- poj 1094 (拓扑排序,注意三种情况出现的优先级)
- 如何现实servlet的单线程模式
- MFC定制应用程序外观
- Java中的instanceof关键字
- 编程语言的发展趋势及未来方向
- 最近公共祖先问题(LCA)
- hdu 1527 取石子游戏