3个回答
展开全部
public class Demo {
/**
* @param args
*/
public static void main(String[] args) {
String s="ad 90 s-=-3 aA";
StringBuilder sb=new StringBuilder(s);
StringBuilder isNum=new StringBuilder();
for(int i=0;i<sb.length();i++){
char c=sb.charAt(i);
if(Character.isDigit(c)){
isNum.append(c);
}
}
System.out.println("数字为:"+isNum.toString());
}
}
/**
* @param args
*/
public static void main(String[] args) {
String s="ad 90 s-=-3 aA";
StringBuilder sb=new StringBuilder(s);
StringBuilder isNum=new StringBuilder();
for(int i=0;i<sb.length();i++){
char c=sb.charAt(i);
if(Character.isDigit(c)){
isNum.append(c);
}
}
System.out.println("数字为:"+isNum.toString());
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(true){
System.out.println("请输入:");
String s = scanner.next();
String str = s.replaceAll("[a-zA-Z]", "");
System.out.println(str.trim());
}
}
Scanner scanner = new Scanner(System.in);
while(true){
System.out.println("请输入:");
String s = scanner.next();
String str = s.replaceAll("[a-zA-Z]", "");
System.out.println(str.trim());
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var c:char;
begin
repeat
read(c);
if c in ['0'..'9'] then write(c)
until eoln;
writeln;
end.
begin
repeat
read(c);
if c in ['0'..'9'] then write(c)
until eoln;
writeln;
end.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询