Topic: 請問怎樣寫一個A~Z 對應 0~25 |
Print this page |
1.請問怎樣寫一個A~Z 對應 0~25 | Copy to clipboard |
Posted by: angus203 Posted on: 2005-10-30 12:04 例如當我輸入B時,就顯示1... 不知道應該怎樣做? |
2.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: angus203] | Copy to clipboard |
Posted by: hualee Posted on: 2005-10-30 15:28 个人简单思路:转换成ascII码,判断其大小写。再计算:输入字符值减去第一个A或a,既输出为0~25。 不过我有个疑问问其他大哥,怎样把单个字符全部转换成小写? 代码:
|
3.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: hualee] | Copy to clipboard |
Posted by: angus203 Posted on: 2005-11-01 07:56 如果輸入多於一個英文,又怎樣檢測? e.g welcome to java |
4.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: hualee] | Copy to clipboard |
Posted by: bluecrystal Posted on: 2005-11-01 12:54 hualee wrote: |
5.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: hualee] | Copy to clipboard |
Posted by: hualee Posted on: 2005-11-02 22:49 谢谢楼上的 |
6.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: angus203] | Copy to clipboard |
Posted by: hualee Posted on: 2005-11-02 22:50 lz后来的消息是什么意思,我不是太懂。。。。 |
7.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: angus203] | Copy to clipboard |
Posted by: qichuan Posted on: 2005-11-03 21:51 I have another approach, you can use a String class method: compareTo, but first you have to declare your input as a String i.e. String input = "B"; int answer = B.compareTo("A"); then you can obtain the result:1. |
8.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: angus203] | Copy to clipboard |
Posted by: truthawp Posted on: 2005-11-04 17:21 基本思路就是变量类型的转换,如果是多输入或者是错误类型输入可以用异常捕捉;还有,大小写转换可以用STRING里的方法(一时想不起名字了 :p) |
9.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: angus203] | Copy to clipboard |
Posted by: gysunny Posted on: 2005-11-05 11:36 转换大写是不是这个 UPPER() 转换小写是不是这个 LOWER() 如果不是,请大家帮忙改正一下。 |
10.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: angus203] | Copy to clipboard |
Posted by: qichuan Posted on: 2005-11-05 12:40 I don't think so, the method converts letters to upper case is "toUpperCase()", and the other one is toLowerCase(); |
11.Re:請問怎樣寫一個A~Z 對應 0~25 [Re: angus203] | Copy to clipboard |
Posted by: hualee Posted on: 2005-11-07 22:03 LZ,对字符串些个循环用index取出每个字符,然后做判断 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |