Children's Day
2013-09-08 23:42
190 查看
这种其实是一个很简单的找规律的题,只要细心,规律很快就能找到,不过写代码的时候更要细心,因为毕竟还没能到达瞬间出题的那种境界···所以要平静下心来写,这样才效率。
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
char s[30];
s[0]='z',s[1]='a',s[2]='b',s[3]='c',s[4]='d';
s[5]='e',s[6]='f',s[7]='g',s[8]='h',s[9]='i';
s[10]='j',s[11]='k',s[12]='l',s[13]='m',s[14]='n';
s[15]='o',s[16]='p',s[17]='q',s[18]='r',s[19]='s';
s[20]='t',s[21]='u',s[22]='v',s[23]='w',s[24]='x';
s[25]='y';
int cur=1,mod=26;
for(int size=3;size<=10;size++){
for(int i=1;i<=size;i++){
if(i==1||i==size){
cout<<s[cur%mod];
for(int j=2;j<=size-1;j++)cout<<" ";
cout<<s[(cur+size+size-2)%mod]<<endl;
}
else{
cout<<s[cur%mod];
for(int j=2;j<=size-i;j++)cout<<" ";
cout<<s[(cur+(size-i)*2)%mod];
for(int j=size-i+2;j<=size-1;j++)cout<<" ";
cout<<s[(cur+size+size-2)%mod]<<endl;
}
if(i!=size)cur++;
}
cur+=size+size-2+1;
}
system("pause");
return 0;
}
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
char s[30];
s[0]='z',s[1]='a',s[2]='b',s[3]='c',s[4]='d';
s[5]='e',s[6]='f',s[7]='g',s[8]='h',s[9]='i';
s[10]='j',s[11]='k',s[12]='l',s[13]='m',s[14]='n';
s[15]='o',s[16]='p',s[17]='q',s[18]='r',s[19]='s';
s[20]='t',s[21]='u',s[22]='v',s[23]='w',s[24]='x';
s[25]='y';
int cur=1,mod=26;
for(int size=3;size<=10;size++){
for(int i=1;i<=size;i++){
if(i==1||i==size){
cout<<s[cur%mod];
for(int j=2;j<=size-1;j++)cout<<" ";
cout<<s[(cur+size+size-2)%mod]<<endl;
}
else{
cout<<s[cur%mod];
for(int j=2;j<=size-i;j++)cout<<" ";
cout<<s[(cur+(size-i)*2)%mod];
for(int j=size-i+2;j<=size-1;j++)cout<<" ";
cout<<s[(cur+size+size-2)%mod]<<endl;
}
if(i!=size)cur++;
}
cur+=size+size-2+1;
}
system("pause");
return 0;
}
相关文章推荐
- HDU 4706 Children's Day(模拟啊)
- HDU 4706 Children's Day(模拟)
- hdu 4706 Children's Day
- HDU4706——Children's Day(简单模拟)
- hdu 4706 (是暴力?还是愚蠢?)Children's Day
- HDU-#4706 Children's Day(模拟)
- Children of a Lesser Python
- PKU 3083 Children of the Candy Corn 这题感触很多。。。。。。。。。。。。。。
- In South Korea had children age
- Cannot create children for a parent that is in a different thread
- UpdatePanel 的 UpdateMode 和 ChildrenAsTriggers(较好的总结了前面几篇博客的内容)
- 视图学习:v$Latch (X$KSLLT) 与 v$Latch_Children(X$KSLLT, X$KSLLD)
- 【HDU 1297】Children’s Queue
- Jquery的parent,parents与children
- Jquery中next和children的区别
- 高性能JS--比较nextSibling,ChildNodes,Children速度
- Titanium 获取win的children的正确方法
- uva 10905 - Children's Game
- jquery遍历之children()与find()的区别
- JQuery. Parse XML children recursively. How? - Stack Overflow