1. 程式人生 > >HDOJ 2013_大二寫

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; }