Fork me on GitHub

牛客网编程练习之编程马拉松:解读密码

image

 

AC代码:

import java.util.Scanner;

/**
 * @author CC11001100
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		while (sc.hasNextLine()){
			System.out.println(decode(sc.nextLine()));
		}
		
	}

	private static String decode(String s){
		StringBuilder res = new StringBuilder();
		for(int i=0; i<s.length(); i++){
			char c = s.charAt(i);
			if(Character.isDigit(c)){
				res.append(c);
			}
		}
		return res.toString();
	}

}

 

题目来源: https://www.nowcoder.com/practice/16fa68271ee5448cafd504bb4a64b482?tpId=3&tqId=10927&tPage=1&rp=&ru=/ta/hackathon&qru=/ta/hackathon/question-ranking

posted @ 2017-12-11 02:12  CC11001100  阅读(213)  评论(0编辑  收藏  举报