All pastes #213901 Raw Edit

Untitled

public text v1 · immutable
#213901 ·published 2006-10-21 18:16 UTC
rendered paste body
#include <math.h>
#include<stdio.h>
#include <stdlib.h>
int main(void)
{
	unsigned int d;
	unsigned char *a;
	unsigned int j, n, q, z, t,s;
    int i;
    double p;
    scanf("%ld",&s);
    while(s--)
    {
    scanf("%ld",&n);
    p = 0.0; 
    for(j = 2; j <= n; j++)
    p += log10(j);
    d = (int)p + 1;
       for (i = 1; i < d; i++)
    a[i] = 0;
    a[0] = 1;
    p = 0.0;
    for (j = 2; j <= n; j++)
    {
		q = 0;
        p += log10(j);
        z = (int)p + 1;
        for (i = 0; i <= z; i++)
        {
	        t = (a[i] * j) + q;
            q = (t / 10);
            a[i] = (char)(t % 10);
        }
    }
    for( i = d -1; i >= 0; i--)
    	printf("%ld",(int)a[i]);
  
} 
     return 0;
 }