首页 > 代码库 > NYOJ题目457大小写互换

NYOJ题目457大小写互换

技术分享

-------------------------------

AC代码:

 1 import java.util.Scanner; 2  3 public class Main { 4  5     public static void main(String[] args) { 6          7          8          9         Scanner sc=new Scanner(System.in);10         11         int n=Integer.parseInt(sc.nextLine());12         13         while(n-->0){14             15             char cs[]=sc.nextLine().toCharArray();16             17             for(int i=0;i<cs.length;i++){18                 if(cs[i]>=‘a‘ && cs[i]<=‘z‘) cs[i]-=32;19                 else cs[i]+=32;20             }21             22             System.out.println(new String(cs));23             24         }25         26     }27     28 }

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=457

NYOJ题目457大小写互换