简单的编程题 懂的都进啊

zhuhanjie123 2009-07-22 10:05:15
编写程序,讲字母表顺序和逆序每隔一个字母打印,即打印出:acegikmoqsuwyzxvtrpnljhfdb。
...全文
142 13 打赏 收藏 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
lianyangshiyan 2009-07-23
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 preferme 的回复:]
Java codeboolean crease=true;int i=0;while(i>=0){
System.out.print((char)(i+'a'));if(crease&& i==26){i++;crease=false;}if(crease)i+=2;else i-=2;
}
[/Quote]
很强大!!!!!!!
bigbug9002 2009-07-23
  • 打赏
  • 举报
回复
看错了.
bigbug9002 2009-07-23
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 preferme 的回复:]
Java codeboolean crease=true;int i=0;while(i>=0){
System.out.print((char)(i+'a'));if(crease&& i==26){i++;crease=false;}if(crease)i+=2;else i-=2;
}
[/Quote]


有点问题,不过三种思路,不错啊.
冰思雨 2009-07-23
  • 打赏
  • 举报
回复

boolean crease = true;
int i=0;
while(i>=0){
System.out.print((char)(i+'a'));
if(crease && i==26){i++;crease=false;}
if(crease)i+=2;
else i-=2;
}
冰思雨 2009-07-23
  • 打赏
  • 举报
回复

Stack<Character> s = new Stack<Character>();
for(int i=0;i<=26;i++){
if(i%2==1)s.push((char)(i+'a'));
else System.out.print((char)(i+'a'));
}
for(char ch:s){
System.out.print(ch);
}
冰思雨 2009-07-23
  • 打赏
  • 举报
回复

for(int i=(int)'a';i<=(int)'z';i+=2){
System.out.print((char)i);
}
for(int i=(int)'x';i>='b';i-=2){
System.out.print((char)i);
}
xuweifeng0323 2009-07-23
  • 打赏
  • 举报
回复
count++??
zhuhanjie123 2009-07-23
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 preferme 的回复:]
Java codefor(int i=(int)'a';i<=(int)'z';i+=2){
System.out.print((char)i);
}for(int i=(int)'x';i>='b';i-=2){
System.out.print((char)i);
}
[/Quote]用这个方法最后显示里没有Z
jiannye 2009-07-22
  • 打赏
  • 举报
回复
楼主知道A的ASCII码吧?
输出while(A的ASCII<count)
{
输出字符 然后count++;
}

这伪代码不错吧? 嘿嘿
ouyangyh 2009-07-22
  • 打赏
  • 举报
回复
使用char就可以了
char c='a';
c+=2;
最近判断一个边界
BurnedVanilla 2009-07-22
  • 打赏
  • 举报
回复
很简单的题哈!只有字母的话看ASCII码就可以了,循环时变量自增2.
Edwin603 2009-07-22
  • 打赏
  • 举报
回复
这有难度么
GGMMYQL 2009-07-22
  • 打赏
  • 举报
回复
楼下的来 写个 哈哈

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧