您的位置:首页 > 其它

杭电2549 壮志难酬

2016-12-22 20:49 253 查看
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
double d = sc.nextDouble();
int n = sc.nextInt();
String str = String.valueOf(d);
int start = str.indexOf(".");
String PointbBehind = str.substring(start+1, str.length());
int lenght = PointbBehind.length();
if (lenght >= n) {
char result = PointbBehind.charAt(n - 1);
System.out.println(result);
} else if(lenght<n){
System.out.println("0");
}else{
}
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息