Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

c±àдdll¹©c#µ÷ÓÃ

1.н¨dll¹¤³Ì£¬ÔÚº¯ÊýÇ°ÃæÔö¼Ó extern "C" __declspec(dllexport) double __stdcall
double Ϊº¯Êý·µ»ØÖµÀàÐÍ
// log.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#define PI 3.14159
double AverageRandom(double min,double max)//²úÉú(min,max)Ö®¼ä¾ùÔÈ·Ö²¼µÄËæ»úÊý
{
int MINnteger = (int)(min*10000);
int MAXnteger = (int)(max*10000);
int aa=rand();
int bb=rand();
int randInteger = aa*bb;
int diffInteger = MAXnteger - MINnteger;
int resultInteger = randInteger % diffInteger + MINnteger;
return resultInteger/10000.0;
}
double LogNormal(double x,double miu,double sigma) //¶ÔÊýÕý̬·Ö²¼¸ÅÂÊÃܶȺ¯Êý
{
return 1.0/(x*sqrt(2*PI)*sigma) * exp(-1*(log(x)-miu)*(log(x)-miu)/(2*sigma*sigma));
}
extern "C" __declspec(dllexport) double __stdcall Random_LogNormal(double miu,double sigma,double min,double max)//²úÉú¶ÔÊýÕý̬·Ö²¼Ëæ»úÊý
{

double x;
double dScope;
double y;
do
{
x = AverageRandom(min,max);
y = LogNormal(x, miu, sigma);
dScope = AverageRandom(0, LogNormal(miu,miu,sigma));
}while( dScope > y);
return x;
}
2.C#ÖдúÂë
  //ͨ¹ýDllImportÒýÓÃlog.dllÀà¡£Random_LogNormalÀ´×ÔÓÚlog.dllÀà
    [DllImport("log.dll", EntryPoint = "Random_LogNormal")]
    public static extern double Random_LogNormal(double miu, double sigma, double min, double max);
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
class Program
{
///****************************************************
/// ²úÉúN=100¸öÔÚ£¨0,50£©Çø¼äÄÚÂú×ã¶ÔÊýÕý̬·Ö²¼µÄËæ»úÊý
///*****************************************************/
const int N = 100;
const int MAX = 30;
const double MIN = 0.5;


Ïà¹ØÎĵµ£º

C ±ê×¼¿â º¯Êý Ô´´úÂëµÄʵÏÖ ºÍ ·ÖÎö

//¿âº¯ÊýʵÏÖ
char *strcat (char *dst, const char *src)
{
  char *p = dst;
  while (*p)
    p++;
  while ((*p++ = *src++))
    ;
  return dst;
}
char *strncat (char *s1, const char *s2, long unsigned int n)
{
  char *dest = s1;
  ......

cµÄIO

²¿·ÖÄÚÈÝÀ´×Ôhttp://www.programfan.com/article/2674.htmlÒÔ¼°http://www.programfan.com/article/showarticle.asp?id=2675
²¿·Ö·­ÒëÀ´×ÔTUM skript£¨c programmieren);
1.printf()£º
ǧÍò²»ÒªÒÅÍüÔÚprintf()µÄ×îºóÌí¼ÓNewLine"\n"¡£ÒòΪÔÚcµÄ¿âÖÐͨ³£ÓÐÐлº´æ»úÖÆ£¬Õâ¸öÒâζ×ÅÖ»Óе±Ò»ÐеÄÊäÈëͨ¹ý"\n"½áÊøÖ®Ç°£¬ÐеÄÊ ......

C×Ö·û´®·´×ªËã·¨

Ò»¸öºÜ¼ò½àµÄËã·¨£º
void Reverse(char s[])
{
    for(int i = 0, j = strlen(s) - 1; i < j; ++i, --j) {
        char c = s[i];
        s[i] = s[j];
        s[j] = c;
 & ......

¡¾×ª¡¿C´úÂëÓÅ»¯·½°¸


1¡¢Ñ¡ÔñºÏÊʵÄËã·¨ºÍÊý¾Ý½á¹¹
Ñ¡ÔñÒ»ÖÖºÏÊʵÄÊý¾Ý½á¹¹ºÜÖØÒª£¬Èç¹ûÔÚÒ»¶ÑËæ»ú´æ·ÅµÄÊýÖÐʹÓÃÁË´óÁ¿µÄ²åÈëºÍɾ³ýÖ¸ÁÄÇʹÓÃÁ´±íÒª¿ìµÃ¶à¡£Êý×éÓëÖ¸ÕëÓï¾ä¾ßÓÐÊ®·ÖÃÜÇеĹØÏµ£¬Ò»°ãÀ´Ëµ£¬Ö¸Õë±È½ÏÁé»î¼ò½à£¬¶øÊý×éÔò±È½ÏÖ±¹Û£¬ÈÝÒ×Àí½â¡£¶ÔÓڴ󲿷ֵıàÒëÆ÷£¬Ê¹ÓÃÖ¸Õë±ÈʹÓÃÊý×éÉú³ÉµÄ´úÂë¸ü¶Ì£¬Ö´ÐÐЧÂʸü¸ß¡£
ÔÚÐí¶à ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ