本帖最后由 崔一恒 于 2013-7-21 20:31 编辑
- import java.io.*;
- class Test5 {
- public static void main(String[] args) throws IOException {
-
- BufferedReader bufr =
- new BufferedReader(new InputStreamReader(System.in));
- BufferedWriter bufw =
- new BufferedWriter(new OutputStreamWriter(System.out));
- String line = null;
- while((line=bufr.readLine())!=null){
- if("over".equals(line))
- break;
- bufw.write(line);
- bufw.newLine();
- bufw.flush();
- }
- bufr.close();
- char[] arr=line.toCharArray();
复制代码- for(int i=0;i<arr.length;i++){
- if(arr[i]>='A'&&arr[i]<='Z')
- arr[i]=(char)(arr[i]+32);
- else if(arr[i]>='a'&&arr[i]<='z')
- arr[i]=(char)(arr[i]-32);
- }
-
-
- System.out.println(arr);
-
- }
- }
复制代码 求助:运行这段代码,没有实现大小写互换,只在输入over时对over进行小写转大写了,这该如何改进
|