标签:style blog http color strong io for 2014
1 /* 2 * Main.c 3 * C16-循环-16. 猴子吃桃问题 4 * Created on: 2014年8月2日 5 * Author: Boomkeeper 6 *********测试通过******** 7 */ 8 9 #include <stdio.h> 10 /* 11 * 根据天数N计算桃子数量 12 */ 13 int monkeyEatPeach(int N) { 14 15 int i, sum = 1; 16 17 for (i = 2; i <= N; i++) { 18 sum = (sum + 1) * 2; 19 } 20 21 return sum; 22 } 23 24 int main(void) { 25 26 int N; //题目中的N,天数 27 28 scanf("%d", &N); 29 printf("%d\n", monkeyEatPeach(N)); 30 31 return 0; 32 }
题目链接:
http://pat.zju.edu.cn/contests/basic-programming/%E5%BE%AA%E7%8E%AF-16
标签:style blog http color strong io for 2014
原文地址:http://www.cnblogs.com/boomkeeper/p/C16.html