另一種用C++寫九九乘法表的方法

// ver 1.0 written by novus march 2008

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

template <int M, int N> struct A : A<M, N-1> {
A () {cout << M << "*" << N << "=" << M*N << "\t";}
};

template <int M> struct A<M, 1> : A<M-1, 9> {
A () {cout << endl << M << "*" << 1 << "=" << M << "\t";}
};

template <> struct A<1, 1> {
A () {cout << 1 << "*" << 1 << "=" << 1 << "\t";}
};

A<9,9> a;
int main() { }
arrow
arrow
    全站熱搜

    novus 發表在 痞客邦 留言(2) 人氣()