分数 10
输入一行英文,字符数不超过100,请将此行中大写字母变小写,小写字母变大写。
输入格式:
输入不超过100个字符的英文句子。
输出格式:
输出大写小写字母变换后的英文句子。
输入样例:
在这里给出一组输入。例如:
Don’t believe that winning is really everything. It’s more important to stand for something. If you don’t stand for something, what do you win!
输出样例:
在这里给出相应的输出。例如:
dON’T BELIEVE THAT WINNING IS REALLY EVERYTHING. iT’S MORE IMPORTANT TO STAND FOR SOMETHING. iF YOU DON’T STAND FOR SOMETHING, WHAT DO YOU WIN!
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB
代码如下:
import java.io.*;
public class Main{
static BufferedReader ins= new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer in= new StreamTokenizer(ins);
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException{
String S = ins.readLine();
int a=S.length();
char[] c = S.toCharArray();
for(int i=0;i<a;i++){
if('a'<=c[i]&c[i]<='z'){
c[i]=(char)(c[i]-32);
}
else if('A'<=c[i]&c[i]<='Z'){
c[i]=(char)(c[i]+32);
}
}
out.print(c);
out.close();
}
}
查看上次提交
提交本题作答