题目链接:http://codeforces.com/problemset/problem/697/B
题目大意:
将科学计数法用十进制表示。【如果类似于7.0应输出7】
解题思路:
Java 中 BigDecimal 类型可以直接对其转,注意输出。
AC Code:
1 import java.math.BigDecimal; 2 import java.util.Scanner; 3 4 public class Main { 5 public static void main(String[] args) { 6 Scanner sc = new Scanner(System.in); 7 while (sc.hasNext()) { 8 String s = sc.nextLine(); 9 BigDecimal db = new BigDecimal(s); 10 char[] ss = db.toString().toCharArray(); 11 if (ss[ss.length - 1] == '0' && ss[ss.length - 2] == '.') 12 System.out.println(db.toString().substring(0, ss.length - 2)); 13 else 14 System.out.println(db.toPlainString()); 15 } 16 } 17 }