摘要: 1、(10分)求20+21+22+23+…+2n的和,n=20。 1 //刚开始想一个一个算再加一块,后来想到了求和公式 2 #include <iostream> 3 #include <cstring> 4 using namespace std; 5 6 int fun(int a,int b)//或者直接(2<<20-1或者1<<21-1) 7 { 8 int temp,ans; 9 if(0==b)10 return 1;11 temp = fun(a,b/2);12 ans = temp*temp;13 ... 阅读全文
posted @ 2012-12-09 10:52 加拿大小哥哥 阅读(1300) 评论(3) 推荐(0)