| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1603 人关注过本帖
标题:加分答题
只看楼主 加入收藏
Anstey
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2004-4-14
收藏
 问题点数:0 回复次数:13 
加分答题

OK刚刚我看C那里有一个叫有奖答题的东东。现在我也写个题目。第一个答对的有50分的加分(版主除外)。

In case you guys want to get used to Java English, i will write the whole thing in English

(In face, it is also a bit hard for me to translate all the Java word into Chinese,:P, sorry guys)

Ok, I promise the question i write (and maybe future??) will be nice and simple so that most of people here will actually have a chance to do this (and at least think).

=====================================================================

Here comes the Question.

Write a class, called Reverse.java, which takes an command line argument, and print that String back to the screen but in its reverse order.There are lots of ways to do the simple task!!!

For example:

C:\javaPro\java Reverse apple

elppa <<<<<this is the output

C:\javaPro\java Reverse a

a <<<<<<this is the output

C:\javaPro\java Reverse "apple tree"

eert elppa <<<<<<this is the output

(you can assume that the user will enter at lease one character so that no Exception will be ever thrown...

Extension: If no loop is allowed in this question, what will you do it? (if you could do without any loops in the class, +60 :-) )

Have Fun!!!

=====================================================================

Important: When you reply, do not just write a post and reply, please upload an attachment as a .java file (in this case Reverse.java), to do this, it will make much simpler when you are writing the program and it is also easy for others (including me) to check if your program works or not (since we can run it straightaway without copy and paste).

If you are the 1st, and 50 will be added!

[此贴子已经被作者于2004-09-15 21:04:05编辑过]

搜索更多相关主题的帖子: 答题 
2004-09-15 20:34
lyn_gemini
Rank: 1
等 级:新手上路
帖 子:103
专家分:3
注 册:2004-9-15
收藏
得分:0 

Here is my programme for this question, and i accomplished it without any loop.

What should you do now , Anstey ? ^_^

dwaAeSBf.rar (1 KB) 加分答题

Well done! A tuff approch using recursion, and in fact this is what i expect by saying "using no loop"

As I promise, 60 will be added.

Thanks.

--------by Anstey

[此贴子已经被Anstey于2004-09-16 15:34:07编辑过]


欢迎访问我的博客--*IT一粟*-- : http://lyn_gemini.
2004-09-16 13:24
Anstey
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2004-4-14
收藏
得分:0 

虽然已经有第一个60, 因为只有一个回复,所以50仍然有效,so keep doing it.....!!!

可能问题简单了一点。。。呵呵,ANYWAY。。

下次会更难一点。。。。呵呵 maybe....


Anstey. Cheers. I love CAPPUCCINO~~
2004-09-16 15:31
lyn_gemini
Rank: 1
等 级:新手上路
帖 子:103
专家分:3
注 册:2004-9-15
收藏
得分:0 

50 is also available? But i think it's too .....if we accoplish it with a loop. Since Anstey has claimed that such a programme with a loop can also derive 50, i will have a try. ^_^

[attach]812[/attach]

欢迎访问我的博客--*IT一粟*-- : http://lyn_gemini.
2004-09-16 20:42
Anstey
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2004-4-14
收藏
得分:0 

No, I am sorry, I have already added 60 to you....

Dont be too...... :


Anstey. Cheers. I love CAPPUCCINO~~
2004-09-17 16:48
lyn_gemini
Rank: 1
等 级:新手上路
帖 子:103
专家分:3
注 册:2004-9-15
收藏
得分:0 
Such a sequence is in my expect........................

欢迎访问我的博客--*IT一粟*-- : http://lyn_gemini.
2004-09-17 23:27
lyn_gemini
Rank: 1
等 级:新手上路
帖 子:103
专家分:3
注 册:2004-9-15
收藏
得分:0 
Anstey, I think it's better that you let your such an information about adding scores through design programmes you assigned be known by many people, otherwise it's very likely that i am the only one who engages in your topic.

欢迎访问我的博客--*IT一粟*-- : http://lyn_gemini.
2004-09-17 23:32
藏马
Rank: 2
等 级:新手上路
威 望:3
帖 子:25
专家分:0
注 册:2004-7-16
收藏
得分:0 
Can you say Chinese? I don`t speak English!!!

2004-09-21 15:57
goldfire
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2004-11-21
收藏
得分:0 

import javax.swing.JOptionPane;

class Reverse{ public static void main(String args[]){ String output ="" ; int i , j , k ; String input = JOptionPane.showInputDialog("Please Enter String") ; if (input.length() <= 60){ for ( i = input.length() -1 ; i > 0 ; i--) output+= input.charAt( i ); } else for( i = input.length() -1 ; i >0 ; i-- ) for ( i = input.length(), j= 0 ; j<i/60 ; j++){ output+= input.charAt( i ); output+= "\n" ; } // System.out.println("The Reversion of the String is : " +output) ; JOptionPane.showMessageDialog( null , output, "Reverse Program", JOptionPane.PLAIN_MESSAGE); System.exit(0); } }

我是一个新手,编了一段这样的程序,可是不能实现原题的目的(字符串的最后一个字母总是显示不出来),请各位高手指点啊

2004-11-22 21:53
ft5032839
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2004-11-30
收藏
得分:0 
我的英语不太好,看不懂.
2004-12-07 21:51
快速回复:加分答题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022014 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved