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

Çó·½³Ìax^2+bx+c=0µÄ¸ù(º¯Êý)

#include<stdio.h>
#include<math.h>
float x1,x2,disc,p,q;
int main()
{
void greater_than_zero(float,float);
void equal_to_zero(float,float);
void smaller_than_zero(float,float);
float a,b,c;
printf("\ninput a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
printf("equation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c);
disc=b*b-4*a*c;
printf("root:\n");
if(disc>0)
{
greater_than_zero(a,b);
printf("x1=%f\t\tx2=%f\n",x1,x2);
}
else if(disc==0)
{
equal_to_zero(a,b);
printf("x1=%f\t\tx2=%f\n",x1,x2);
}
else
{
smaller_than_zero(a,b);
printf("x1=%f+%fi\tx2=%f-%fi\n",p,q,p,q);
}
system("pause");
}
void greater_than_zero(float a,float b)
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
}
void equal_to_zero(float a,float b)
{
x1=x2=(-b)/(2*a);
}
void smaller_than_zero(float a,float b)
{
p=-b/(2*a);
q=sqrt(-disc)/(2*a);
}


Ïà¹ØÎĵµ£º

C++ÍêÈ«¼æÈÝCµÄÓï·¨Âð£¿

¶ÔÓÚC±àд³ÌÐò£¬´ó²¿·Ö¶¼¿ÉÒÔͨ¹ý£¬µ«ÊDz»»áÍêÈ«¼æÈÝ£¬¾ÙÁ½¸öÀý×Ó£º
1.
char *str;
str = malloc(32);
2.
char ch[3] = "abc";
gcc  -g  -o test test.c
g++ -g -o test test.c
ÒòΪC++¼ì²é¸ü¼ÓÑϸñ£¬CûÓÐÕâôÑϸñ¡£
´ó¼Ò¿ÉÒԱȽÏһϣ¬gcc²»»á±¨´í£¬g++»á±¨´í¡£
Èç¹û´ó¼Ò»¹ÓÐеÄcase,»¶Ó­ ......

C bulider¼ÆËãÆ÷³õ²½

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
int   flag=0; // ......

CÍ·ÎļþÏ໥°üº¬µÄÎÊÌâ

     ÔÚC++ÖУ¬¹ØÓÚCPPµÄÍ·Îļþ»¥Ïà°üº¬µÄÎÊÌâºÜÈÃÈËÍ·ÌÛ£¬ÆäʵÎÒÃÇË­Ò²²»Ô¸ÒâŪµÄ½á¹¹»ìÂÒ£¬ÄÑÒÔÀí½â£¬µ«ÓÐʱÓÖÊÇÓбØÐëµÄ¡£
     ¼Ù¶¨µ±Ç°ÓÐÁ½¸öÍ·Îļþ·Ö±ðΪ A.h  ºÍ B.h£¬ÄÚÈÝ·Ö±ðÈçÏ£º
     A.hÄÚÈÝΪ£º
     #ifndef  ......

C/C++µ¥Ôª²âÊÔÀíÂÛ¾«Òª£¨ËÄ£©

ÌâÍâƪ£ºµ¥Ôª²âÊÔÄÑÓÚ³¤ÆÚ¼á³ÖµÄÔ­ÒòÓë½â¾ö̽ÌÖ
    ÉÏһƪ¡¶µ¥Ôª²âÊÔЧÒæ¡·£¬ÓÐÍøÓÑÆÀÂÛ˵£º“µ¥Ôª²âÊԵĺô¦»ù±¾ÈËÈËÖªµÀ£¬¾ÍÊÇÄѼá³Ö£¡”¡£ÕâÒ»ÆÀÂÛÑÏÖØÌáÐÑÁËÎÒ£¬²»´í£¬“ÄѼá³Ö”Ò²ÊÇÒ»¸öÆÕ±éÏÖ×´¡£Èç¹û²»Äܼá³Ö£¬ÄÇÒ»Çж¼ÊÇ°×´î¡£Òò´Ë£¬ÕâÀï²åÈëÒ»¸öÌâÍâƪ£¬Ì½ÌÖµ¥Ôª²âÊÔÄÑÓÚ³¤Æ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ