Simple n! Time limit:1000ms Memory limit:65536k have questions? Dot here ^_^ The title describes a given number n (0 <= n <= 150), which is the factorial of 0 to N. Input
The topic has multiple sets of data that are processed to the end of the file. Enter a number n.
Output
Output factorial, in the form of: 4! = 24. Each set of data is output followed by a blank line.
Sample input
14
Sample output
0! = 11! = 10! = 11! = 12! = 23! = 64! = 24
Hint Code:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm> #include < iostream> #include <iomanip> #include <cctype> #include <string>using namespace std;//implementation 1-> 150 factorial int main () {int r[601];int I, J, K, C;int t; int N;while (scanf ("%d", &n)!=eof) {if (n==0) {printf ("0!) = 1\n\n "); continue;} if (n==1) {printf ("0! = 1\n1! = 1\n\n "); continue;} printf ("0! = 1\n1! = 1\n "); for (i=0; i<=600; i++) {r[i]=0;} R[0]=j=1; For (i=2, i<=n; i++) {for (k=0; k<j; k++) {r[k]=r[k]*i;} for (k=c=0; k<j; k++) {t=r[k]+c; r[k]=t%10; C=T/10;} while (c) {r[j]=c%10; C=C/10; j + +;} The rounding problem that deals with that part of the high//printf ("%d---\ n", j); printf ("%d! = ", i); for (k=j-1; k>=0; k--) {printf ("%d", R[k]);} printf ("\ n");} printf ("\ n");} return 0;} Division is not involved! Pending add/**************************************problem id:sdut OJ 2059 result:accepted take memory:496k take time:10ms Sub MIT time:2015-01-11 08:22:42 **************************************/
Sdut OJ 2059 Simple n! (A large number of algorithms multiplied by a decimal, a large number with a fractional division algorithm "template")