Children's Day(4706)
2015-07-29 21:32
295 查看
Today is Children's Day. Some children ask you to output a big letter 'N'. 'N' is constituted by two vertical linesand one diagonal. Each pixel of this letter is a character orderly. No tail blank is allowed.
For example, this is a big 'N' start with 'a' and it's size is 3.
Your task is to write different 'N' from size 3 to size 10. The pixel character used is from 'a' to 'z' continuously and periodic('a' is reused after 'z').
Input
This problem has no input.
Output
Output different 'N' from size 3 to size 10. There is no blank line among output.
Sample Output
[pre]
a e bdf c gh n
i mo
jl p
k q
.........
r j
[/pre]
Hint
Not all the resultsare listed in the sample. There are just some lines. The ellipsis expresseswhat you should write.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <string>
using namespace std;
#define pi acos(-1,0)
int main()
{
int size=3;
int i,j;
char s[11][11];
char c='a';
while(size<11)
{
memset(s,' ',sizeof(s));
for(i=1;i<=size;i++)
{
if(i==1 || i==size)
{
for(j=1;j<=size;j++)
{
s[j][i]=c;
if(c=='z')
c='a';
else
c++;
}
}
else
{
s[size+1-i][i]=c;
if(c=='z')
c='a';
else
c++;
}
}
for(i=1;i<=size;i++)
{
for(j=1;j<=size;j++)
{
printf("%c",s[i][j]);
}
printf("\n");
}
size++;
}
return 0;
}
For example, this is a big 'N' start with 'a' and it's size is 3.
a e bdf c g
Your task is to write different 'N' from size 3 to size 10. The pixel character used is from 'a' to 'z' continuously and periodic('a' is reused after 'z').
Input
This problem has no input.
Output
Output different 'N' from size 3 to size 10. There is no blank line among output.
Sample Output
[pre]
a e bdf c gh n
i mo
jl p
k q
.........
r j
[/pre]
Hint
Not all the resultsare listed in the sample. There are just some lines. The ellipsis expresseswhat you should write.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <string>
using namespace std;
#define pi acos(-1,0)
int main()
{
int size=3;
int i,j;
char s[11][11];
char c='a';
while(size<11)
{
memset(s,' ',sizeof(s));
for(i=1;i<=size;i++)
{
if(i==1 || i==size)
{
for(j=1;j<=size;j++)
{
s[j][i]=c;
if(c=='z')
c='a';
else
c++;
}
}
else
{
s[size+1-i][i]=c;
if(c=='z')
c='a';
else
c++;
}
}
for(i=1;i<=size;i++)
{
for(j=1;j<=size;j++)
{
printf("%c",s[i][j]);
}
printf("\n");
}
size++;
}
return 0;
}
相关文章推荐
- Linux C函数参考手册(PDF版)
- Lua教程(十七):C API简介
- C#实现打造气泡屏幕保护效果
- C/C++数据对齐详细解析
- C 语言基础教程(我的C之旅开始了)[三]
- C++中的extern “C”用法详解
- C 语言基础教程(我的C之旅开始了)[七]
- C字符串操作函数实现方法小结
- C/C++ 宏详细解析
- C/C++实现对STORM运行信息查看及控制的方法
- 用C#生成不重复的随机数的代码
- 在c和c++中实现函数回调
- 浅析C/C++中被人误解的SIZEOF
- C 语言基础教程(我的C之旅开始了)[六]
- C/C++实现的游戏角色名称名字随机生成代码
- C/C++函数调用的几种方式总结
- c/c++中变量的声明和定义深入解析
- 浅析c与c++中struct的区别
- 深入详解C编写Windows服务程序的五个步骤