题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2042

这道题是一个递归题!

 

#include <cstdlib>
#include <iostream>

using namespace std;
int f(int n)                      
{
    if(n==1)
      return 4;
    if(n>1)
      return (f(n-1)-1)*2;
}

int main(int argc, char *argv[])
{
    int n;
    cin>>n;
    while(n--)
    {
      int Station;
      cin>>Station;
      cout<<f(Station)<<endl;
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}

 

 

经常回顾呀~~~~~~~~~~~~

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
  • 2021-07-10
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
猜你喜欢
  • 2022-01-18
  • 2021-06-19
  • 2022-12-23
  • 2021-06-06
  • 2021-05-25
  • 2022-12-23
  • 2021-08-24
相关资源
相似解决方案