弄个题玩玩

小绵羊 2011-08-05 03:46:06
怎样在不使用循环及递归的情况下打印出n个 hello (n>=1) 。

api里的循环也算

挖坟挖出来的个题。
...全文
505 96 打赏 收藏 转发到动态 举报
写回复
用AI写文章
96 条回复
切换为时间正序
请发表友善的回复…
发表回复
小绵羊 2011-08-06
  • 打赏
  • 举报
回复
[Quote=引用 93 楼 zl3450341 的回复:]
居然只给我25分。。。。。。
[/Quote]
shenyanxxxy 2011-08-06
  • 打赏
  • 举报
回复
不好意思 我是拿C语言写的
shenyanxxxy 2011-08-06
  • 打赏
  • 举报
回复
#include<stdio.h>
int printhello(int n)
{static int m = 1;
if(m++!=n)
printf("hello\n");
if(n==1)
{
printf("hello\n");
return 1;
}
if(n<=0)
return 0;
printhello(n-1);
return 1;
}
main()
{
printhello(5);
}
shine333 2011-08-05
  • 打赏
  • 举报
回复

洗澡时候想到的
public class Test {
public static void main(String[] args) {
System.out.println(args[0]);
}
}

java Test "hello hello hello"
zl3450341 2011-08-05
  • 打赏
  • 举报
回复
居然只给我25分。。。。。。
horse_leo_zhcn 2011-08-05
  • 打赏
  • 举报
回复
学习了

先高手看齐
小绵羊 2011-08-05
  • 打赏
  • 举报
回复
回家结分
Alice_Dextrys 2011-08-05
  • 打赏
  • 举报
回复
云计算!!!
zl3450341 2011-08-05
  • 打赏
  • 举报
回复
[Quote=引用 86 楼 x19881216 的回复:]

引用 85 楼 xierong2011 的回复:

看来这里面高手芸芸呀 想拜个师哥 谁有兴趣?

妹子就要
[/Quote]
色狼一头
xiaojinhua1988 2011-08-05
  • 打赏
  • 举报
回复
[Quote=引用 83 楼 gannian 的回复:]

其实答案在这里..哈哈..
public static void main(String[] args) {
System.out.println("n个 hello (n>=1) 。");
}
[/Quote]

人才啊
思夜星云 2011-08-05
  • 打赏
  • 举报
回复
呵呵 ....
小绵羊 2011-08-05
  • 打赏
  • 举报
回复
[Quote=引用 85 楼 xierong2011 的回复:]

看来这里面高手芸芸呀 想拜个师哥 谁有兴趣?
[/Quote]
妹子就要
xierong2011 2011-08-05
  • 打赏
  • 举报
回复
看来这里面高手芸芸呀 想拜个师哥 谁有兴趣?
小赖赖 2011-08-05
  • 打赏
  • 举报
回复
楼上人才啊!
gannian 2011-08-05
  • 打赏
  • 举报
回复
其实答案在这里..哈哈..
public static void main(String[] args) {
System.out.println("n个 hello (n>=1) 。");
}
小绵羊 2011-08-05
  • 打赏
  • 举报
回复
[Quote=引用 81 楼 skyparty 的回复:]

或者写个网页,挂在网上
发广告让大家点,点一次出一个hello,点一次出一个hello
直到达到指定数字
这个方案俗称云计算...
[/Quote]
云计算。。。
计算。。。
算。。。
。。。
。。
小赖赖 2011-08-05
  • 打赏
  • 举报
回复
或者写个网页,挂在网上
发广告让大家点,点一次出一个hello,点一次出一个hello
直到达到指定数字
这个方案俗称云计算...
小赖赖 2011-08-05
  • 打赏
  • 举报
回复
写个print hello的程序
口中默数,100,99,98,97,96,95...5,4,3,2,1
手中默点,数一下就双击一下程序,数一下就双击一下程序...
jingluo 2011-08-05
  • 打赏
  • 举报
回复
。。。递归也不能用 除了一条条打 无解
小绵羊 2011-08-05
  • 打赏
  • 举报
回复
[Quote=引用 77 楼 jingluo 的回复:]

感觉我这可以。。
Java code

int count = 0, max = 16;
void print()
{
System.out.println("hello");
++count ;
if(count < max)
print();
}
[/Quote]
这是递归了
加载更多回复(76)

62,615

社区成员

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

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