稍微修改一下,但一樣是CE
**/
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
typedef unsigned long long int uint64;
uint64 X[100];
template<int n>
struct Array
{
inline static uint64 func() {
return X[n] = Array<n-1>::func() + X[n-2];
}
};
template<>
struct Array<2>
{
inline static uint64 func() {
Array<1>::func();
return X[2] = 2;
}
};
template<>
struct Array<1>
{
inline static uint64 func() {
return X[1] = 1;
}
};
int main(void)
{
Array<92>::func();
const int Max = 80;
int n;
while(scanf("%d",&n)!=EOF)
{
if (n>0 && n<=92)
printf("%llu\n",X[n]);
else
printf("Input out off range!!\n");
}
return 0;
}
稍微修改一下,但一樣是CE
**/
#include
#include
#include
using namespace std;
typedef unsigned long long int uint64;
uint64 X[100];
template
struct Array
{
inline static uint64 func() {
return X[n] = Array::func() + X[n-2];
}
};
template<>
struct Array<2>
{
inline static uint64 func() {
Array<1>::func();
return X[2] = 2;
}
};
template<>
struct Array<1>
{
inline static uint64 func() {
return X[1] = 1;
}
};
int main(void)
{
Array<92>::func();
const int Max = 80;
int n;
while(scanf("%d",&n)!=EOF)
{
if (n>0 && n<=92)
printf("%llu\n",X[n]);
else
printf("Input out off range!!\n");
}
return 0;
}
VC 編譯器不一定按照標準 .. (好像是這樣.)
建議你使用Dev C++ coding.
由於不會物件導向 .
不知道錯誤是什麼 . . .