题目来源:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1835
模拟!
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
char Graph1[5][70] = {
"*****..***..*...*.*****...*...*.*****.*****.***...*****.*...*",
"*.....*...*.*...*.*.......*...*.*...*...*...*..*..*...*..*.*.",
"*****.*****.*...*.***.....*****.*****...*...*...*.*...*...*..",
"....*.*...*..*.*..*.......*...*.*.*.....*...*..*..*...*...*..",
"*****.*...*...*...*****...*...*.*..**.*****.***...*****...*.."
};
char Graph2[61][6] = {
"*****", "*....", "*****", "....*", "*****", ".....", ".***.", "*...*", "*****", "*...*", "*...*", ".....", "*...*",
"*...*", "*...*", ".*.*.", "..*..", ".....", "*****", "*....", "***..", "*....", "*****", ".....", ".....", ".....",
"*...*", "*...*", "*****", "*...*", "*...*", ".....", "*****", "*...*", "*****", "*.*..", "*..**", ".....", "*****",
"..*..", "..*..", "..*..", "*****", ".....", "***..", "*..*.", "*...*", "*..*.", "***..", ".....", "*****", "*...*",
"*...*", "*...*", "*****", ".....", "*...*", ".*.*.", "..*..", "..*..", "..*..",
};
int main()
{
bool flag;
int tmp, n, cnt, i, j;
while(scanf("%d", &n))
{
if(n == 0)
break;
flag = false;
if(n < 0)
{
flag = true;
n = -n;
}
if(!flag)//为整数
{
for(i = 0; i < 5; ++i)
{
tmp = 0;
while(tmp < n)//每一行重复n次
{
for(j = 0; Graph1[i][j]; ++j)//每个点重复n次
{
cnt = 0;
while(cnt < n)
{
printf("%c", Graph1[i][j]);
cnt++;
}
}
tmp++;
printf("\n");
}
}
}
else//为负数
{
for(i = 0; i < 61; ++i)
{
tmp = 0;
while(tmp < n)
{
for(j = 0; Graph2[i][j]; ++j)
{
cnt = 0;
while(cnt < n)
{
printf("%c", Graph2[i][j]);
cnt++;
}
}
++tmp;
printf("\n");
}
}
}
printf("\n\n");
}
return 0;
}