易截截图软件、单文件、免安装、纯绿色、仅160KB

C打印 大数的 阶乘

 6000甚至10000,都可以,但大于6000,就开始滚屏了。。
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int i,j,*f,tmp,c=0;
long int n,bits;
const double PI=2*asin(1.0),E=exp(1.0);
scanf("%ld",&n);
bits=(long)ceil(n*(log10(n)-log10(E))+log10(2*PI*n)/2);
printf("there are %ld digits\n%ld!=",bits,n);
f=(int*)calloc(bits,sizeof(int));
f[0]=1;
for(i=2;i<=n;i++){
for(j=0;j<bits;j++){
tmp=f[j]*i+c;
c=tmp/10;
f[j]=tmp%10;
} }
for(i=bits-1;i>=0;i--) printf("%d",f[i]);
printf("\n");
return 0;
}


相关文档:

C C++ 输出中文【转】


1. wprintf
Q : sizeof(wchar_t) = ?
A : 随编译器不同。(所以:在需要跨平台的时候尽量不用wchar_t) vc : sizeof(wchar_t) = 2;
Q: 在vc中,为什么直接使用wprintf(L"测试1234")会没有结果
A: 没有设置好locale,这样做
setlocale(LC_ALL ,
"
chs
"
);
wprintf(L
"
%s
"
,L
......

C/C++头文件一览

#include <assert.h>    //设定插入点
#include <ctype.h>     //字符处理
#include <errno.h>     //定义错误码
#include <float.h>     //浮点数处理
#include <fstream.h>    //文件输入/输出
#include <iomanip.h>    //参数化输入/输出
#include & ......

JNI 调用C/C++

JNI调用可以加快JAVA的运行速度,主要是将关键的代码用C/C++ 或者mfc完成,在这里贴上我写的一段代码,有兴趣的可以参考:
头文件:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class cn_com_wintone_TLConnectJNI */
#ifndef _Included_cn_com_wintone_TLConnectJ ......

c/c++读写文件

#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;
int main(void)
{
FILE *fp, *fp2;
char buf[1024*300];
fp = fopen("in.txt", "rb");
fp2 = fopen("out.txt", "wb+");
fseek(fp, 0, SEEK_END);
int iLen ......

C 字符串函数大全

函数名: stpcpy
功 能: 拷贝一个字符串到另一个
用 法: char *stpcpy(char *destin, char *source);
程序例:
#include <stdio.h>
#include <string.h>
int main(void)
{
   char string[10];
   char *str1 = "abcdefghi";
   stpcpy(string, str1);
 & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号