HDOJ 2013_大二写

AC代码:

#include <iostream>
#include <cstdio>
using namespace std;

int i=1;
int hanshu(int n, int i)
{
    int count;
    if(i == n)
        count = 1;
    else
        count = 2 * (hanshu(n, i+1) + 1);
    
    return count;
}

int main(void)
{
    freopen("in.txt","r",stdin);
    int n;
    while(scanf("%d",&n) != EOF)
    {
        int sum;
        sum = hanshu(n,i);
        printf("%d\n",sum);
    }
    
    fclose(stdin);
    return 0;
}

 

posted @ 2018-11-09 07:35  pha创噬  阅读(113)  评论(0编辑  收藏  举报