标签:tmp catch 标题 rgs dem void top main 重点
public class demo5 { public static void main(String[] args) { try { PrintStream ps = System.out; PrintStream prs = new PrintStream(new File("C:\\Users\\Laptop\\Desktop\\ans\\ans.txt")); System.setOut(prs); work(123456); System.setOut(ps); } catch (FileNotFoundException e) { e.printStackTrace(); } } private static void work(int n) { BigInteger x = BigInteger.valueOf(2); BigInteger y = BigInteger.valueOf(3); for (int i = 1; i < n; i++) { BigInteger tmp1 = x.multiply(BigInteger.valueOf(2)).subtract(y.multiply(BigInteger.valueOf(3))); BigInteger tmp2 = x.multiply(BigInteger.valueOf(3)).add(y.multiply(BigInteger.valueOf(2))); x = tmp1; y = tmp2; } System.out.println(x + "" + y + "i");// 输出结果 } }
划重点,这个输出到文件代码要记。
标签:tmp catch 标题 rgs dem void top main 重点
原文地址:https://www.cnblogs.com/hardhp74520/p/11739919.html