¿ª·¢ÓïÑÔ¤ÎC - C/C++ / CÓïÑÔ
¼ÆËã1-1/2+1/3-1/4+¡+1/99-1/100+¡,Ö±µ½×îºóÒ»ÏîµÄ¾ø¶ÔֵСÓÚ10-4Ϊֹ¡£
¿ª·¢ÓïÑÔ¤ÎC
ÆÈËÂ𣡲»ÒªÔÚÕâÑùÁË¡£
ÄãµÄÌâºÜ¼òµ¥µÄ£¬¿ÉϧÎÒ²»»á¡£
²»»á£¬²»»á£¬¾ÍÊDz»»á¡£
¸ßÊÖ°ï棺http://topic.csdn.net/u/20100514/22/a0306fbb-4006-49d3-b339-c3ef8eb347aa.html
¤ÎCÊÇʲô£¿CÓïÑÔÊÇÕâÑùµÄ...
C/C++ code:
/*¼ÆËã1-1/2+1/3-1/4+¡+1/99-1/100+¡,Ö±µ½×îºóÒ»ÏîµÄ¾ø¶ÔֵСÓÚ10-4Ϊֹ¡£*/
#include <stdio.h>
#include <math.h>
int main(void)
{
float sum=0,n=1,i=1;
while(fabs(i/n)>1e-4)
{
sum += i/n;
n++;
i = -i;
}
printf("%f\n",sum);
return 0;
}
ÎÒÓеãÔÎÔεĸоõ
[code=C/C++][/code]
#include <iostream>
using namespace std;
void main()
{
int i=1;
double m,sum;
while(m> =10e-4)
{
if(i%2==0)
{m=1/i;sum=sum-m;}
else
{m=1/i;sum=sum+m;}
i++;
}
cout < <sum < <endl;
}
ÊÇC++³ÌÐò£¬Äã×Ô¼º¸Äһϰ¡
ÕæÊÇÎêÈèÁË¿ª·¢¶þ×Ö°¢
Â¥Ö÷Õâ¸ö¼òµ¥µÄ£¬£¬Â¥Ö÷ºÃºÃ¶¯¶¯ÄÔ½î
¿´ÁËÕâ¸öÌâ¾õµÃ¸Ã¸´Ï°Ò»Ï¸ߵÈÊýѧÁË
Ïà¹ØÎÊ´ð£º
дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
±¾ÈËÕýÔÚÓÃJava×öÒ»¸öC/S¼Ü¹¹µÄÏîÄ¿£¬
¿ÉÊÇÓÉÓÚÏîÄ¿±È½Ï´ó£¬Ç°ÆڶԼܹ¹µÄÉè¼ÆÓÈÆäÖØÒª£¬ÒòΪºóÆÚ¿ÉÄÜËæʱ»á¼Ó¸ö¹¦ÄÜ»òÕßÈ¥µôijЩ¹¦ÄÜ¡£
ËùÒÔÌصØÑ°ÇóÈçºÎÉè¼ÆC/SµÄ¼Ü¹¹Ê¹³ÌÐò¸ü¼ÓÃæÏò¶ÔÏó¸ü¼ÓÒ×ÓÚά ......
ËÄÜ°ïÎÒ°ÑÏÂÃæÕâЩ´úÂë¸Ä³ÉVBÐÎʽµÄ£¬¶àлÁË£¬¼±ÓÃ~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[],float g ......
ÎÒ¸Õ°ÑÌ·ºÆÇ¿µÄµÚÈý°æµÄÊéѧÍ꣬ÎÒÖªµÀµÄÓÐC++£¬CºÍÖ¸Õë CȱÏݺÍÏÝÚå Cר¼Ò±ä³É£¬»¹ÓÐÊý¾Ý½á¹¹£¬ÎÒÏëÎÊÎÊÎÒÓ¦¸ÃÒÔʲô˳ÐòÀ´Ñ§ÄØ
CȱÏݺÍÏÝÚå Cר¼Ò±à³Ì
Êǽø½×µÄ£¬²»Óü±×Å¿´
ÖÁÓÚ
CºÍÖ¸Õë
Äã²»Àí½âÖ ......
ÈçºÎ½«Ò»¸öListBoxÖеÄÊý¾Ý´æÔÚÊý¾Ý¿âÖеÄÒ»¸ö×Ö¶ÎÏÂÃ棬²¢ÇÒÿÌõ¼Ç¼µÄ×Ö·û´®¸öÊý²»Ò»¶¨ ÒÔ¼°ÈçºÎ´ÓÊý¾Ý¿âÖжÁÈ¡¸ÃListBoxÖеÄËùÓмǼ
C/C++ code:
//´æÈëÊý¾Ý¿â
void __fastcall TForm1::Button5Click(TO ......