标签:
import java.util.Scanner; /** * Created by Administrator on 2016/4/4. */ public class Main { public static void main(String args[]) { Scanner in = new Scanner(System.in); for (; ; ) { int n = in.nextInt(); if (n == 0) { System.exit(0); } else if (n > 0) { int a = 0, b = 0, c = 0; int d = 1; int sum = 0; for (int i = 1; i < n; i++) { d = d + c; c = b; b = a; a = d; } sum = a + b + c + d; System.out.println(sum); } } } }
标签:
原文地址:http://www.cnblogs.com/chengxu-suanfa/p/5359105.html