Cod sursa(job #1349896)

Utilizator ArambasaVlad Arambasa Arambasa Data 20 februarie 2015 15:48:46
Problema Numerele lui Stirling Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.77 kb
#include <fstream>
#define NMax 201
using namespace std;
ifstream in ("stirling.in");
ofstream out ("stirling.out");
int S_I[NMax][NMax],S_II[NMax][NMax];
void Stirling_Speta_I ()
{
    S_I[1][1]=1;
    for (int n=1;n<NMax;n++)
        for (int m=2;m<=n;m++)
    {
        S_I[n][m]=S_I[n-1][m-1]-(n-1)*S_I[n-1][m];
    }
}
void Stirling_Speta_II ()
{
    S_II[1][1]=1;
    for (int n=1;n<NMax;n++)
        for (int m=2;m<=n;m++)
    {
        S_II[n][m]=S_II[n-1][m-1]-(n-1)*S_II[n-1][m];
    }
}
int main()
{
int i,j;
    int T;
    in>>T;
    while (T)
    {
        int op;
        in>>op>>i>>j;
        if(op==1)
        {
            out<<S_I[i][j];
        }
        if (op==2)
        out<<S_II[i][j];

        T--;

    }
    return 0;
}