题解 | 简写单词

简写单词

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);//如果是大写,直接打印结果
            
        }
        
    }
}

全部评论

相关推荐

狸猫换offer:神通广大的互联网
点赞 评论 收藏
分享
优秀的大熊猫在okr...:多益:此贼,必有同谋,按律,该当连坐!
你不能接受的企业文化有哪...
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务