题解 | 简写单词
简写单词
https://www.nowcoder.com/practice/0cfa856bf0d649b88f6260d878f35bb4?tpId=290&tqId=39937&ru=/exam/oj
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNext()){
char ch = in.next().charAt(0);//读到的单词取首字母即可
if(ch >= 'a' && ch <= 'z') System.out.print((char) (ch-32));//如果是小写,就转大写再打印
else System.out.print(ch);//如果是大写,直接打印结果
}
}
}
深信服公司福利 734人发布


查看14道真题和解析