1樓:匿名使用者
#include"iostream.h"
#include"math.h"
using namespace std; //定義名空間void main()
void panduan(double x,double y,double z)
double mianji(double d,double e,double f) //將void型別改為double型別
2樓:旅春冬
#include
#include
using namespace std;
bool panduan(double x,double y,double z);//函式需要宣告
void mianji(double d,double e,double f);
int main()
{double a,b,c,s;
cout<<"請輸入三角形的邊長"<>a>>b>>c;
mianji(a,b,c);
//cout<>x>>y>>z>>endl;
if (x + y > z && x + z > y && y + z > x)
{//cout<<"能夠成三角形"<>d>>e>>f; //此時應該判斷三邊是否可以組成三角形
if (panduan(d,e,f))
{cout<<"能夠構成三角形"<
你程式的錯誤蠻多的,你可能是一個剛剛開始學c++的,甚至我認為有可能你沒有學過c,或者c的基礎很薄弱,因為你會犯一些語句沒有加分號的錯誤。另外函式的宣告你也搞不清,還有就是函式的返回值你也沒有搞明白。建議你從頭開始仔細的學習。
3樓:匿名使用者
我看著修改了一下:
#include "stdafx.h"
#include
#include "cmath"
using namespace std;
int main()
void panduan(double x, double y, double z)
double mianji(double d, double e, double f)
4樓:smile就是我
#include"iostream"
#include"cmath"
using std::cin;
using std::cout;
using std::endl;
int main()
你看這樣能執行嗎?
函式有返回值就不能為int型,還有cout,cin,endl得用名稱空間,輸入不能用cin>>a,b,c,必須用cin>>a>>b>>c
c語言編寫程式,從鍵盤輸入三角形三條邊長(實數),計算並輸出該三角形三條邊長及面積。
5樓:會飛的小兔子
#include
intmain()
擴充套件資料c語言求楊輝三角形:
intmain()
cout<<"1";//這是輸出每一行的第一個1for(intj=1;j<=i-2;j++)cout<<"1"<
}return0;}
6樓:匿名使用者
#include
#include
#include
int main()
system("pause");}
7樓:
我想你主要是不知道知道三條邊怎麼求面積的問題吧?
已知三角形三邊a、b、c,
則s= √
(「三斜求積」 南宋秦九韶)
8樓:匿名使用者
求三角形面積: s=sqrt(p*(p-a)*(p-b)*(p-c)), p=(a+b+c)/2
用c++編寫程式 輸入的三個數字判斷能否組成三角形,若能判斷是什麼三角形並計算面積和周長
9樓:匿名使用者
#include "stdio.h"
#include "math.h"
void main()
{unsigned char a,b,c,max;
double s,cosab;
puts("請輸入三條邊長:");
scanf("%d %d %d",&a,&b,&c);
//半段能否構成三角形
10樓:
#include
#include
using namespace std;
class qiusanjiao
judge(qiusanjiao &)//判斷是否是三角形以及是什麼三角形
cos1=(a*a+b*b-c*c)/(2*a*b);
cos2=(a*a+c*c-b*b)/(2*a*c);
cos3=(c*c+b*b-a*a)/(2*c*b);
if(cos1<0||cos2<0||cos3<0)cout<<"鈍角三角形"< else if(cos1==0||cos2==0||cos3==0)cout<<"直角三角形"< else cout<<"銳角三角形"< }mianji(qiusanjiao &)};void main() 11樓:匿名使用者 任意兩邊之和大於第三邊不久可以判斷是否是三角形嗎,求周長的話就不用說了吧,三邊相加,呵呵,求面積用那個公式s=1/2*a*b*sin(a和b夾的角),sin()=根號下1-cos()的平方,cos()=(a*a+b*b-c*c)/(2*a*b)。呵呵,我也不知道這演算法對不對啊,不過感覺思路就是這樣的,程式我就不寫啦,呵呵! 12樓:匿名使用者 int a,b,c; a+b>c&&abs(a-b) 面積:s=根號下p*(p-a)*(p-b)*(p-c) 其中p=(a+b+c)/2 程式設計實現:從鍵盤輸入三角形的三邊長a,b,c的值,計算並輸出三角形的面積area 13樓:匿名使用者 //給出三角形的三個邊長a,b,c求三角形的面積//用海**式來計算三角形的面積p=(a+b+c)/2,s=根號下#include #include int main(void) return 0;} 14樓: 請問用什麼語言編寫? c語言程式設計,已知三角形的三邊長a,b,c,計算求三角形面積的公式為: 15樓:丿 程式**如下: #include #include int main() 擴充套件資料: 三角形具有以下性質: 1、三角形任意兩邊之和大於第三邊,任意兩邊之差小於第三邊。 2、在平面上三角形的內角和等於180°(內角和定理)。 3、在平面上三角形的外角和等於360° (外角和定理)。 4、三角形的三條角平分線交於一點,三條高線的所在直線交於一點,三條中線交於一點。 5、三角形的任意一條中線將這個三角形分為兩個面積相等的三角形。 16樓:匿名使用者 1、公式:area = sqrt(s*(s-a)*(s-b)*(s-c)) 2、**: printf("依次輸入a,b,c(空格識別一個數):"); scanf("%f%f%f,",&a,&b,&c); s=(float)0.5*(a+b+c); area = (float)sqrt(s*(s-a)*(s-b)*(s-c)); printf("面積為:%f",area); }擴充套件資料舉例: a=3.67;b=5.43; c=6.21; 1、int main() 參考資料
17樓:匿名使用者 #include int main() else }else printf("\n"); return 0;} 18樓:bboy鶴 #include #include void main() **如上 很簡單的 自己多動手 19樓:匿名使用者 #include #include int main () 20樓:匿名使用者 這個問題不難的,還是自己思考下吧 輸入三角形的三個邊長,利用自定義函式來判斷三角形的形狀、並計算該三角形的面積。 21樓:黑馬程式設計師 判斷是否構成三角形1)判定a>0&&b>0&&c>0(判斷三個數為正數) 對a b c三個數由小到大排序,得到 a(排序,簡化判斷量編制和大於第三邊,兩邊之差小於第三邊的判斷) 判斷a+b>c && c-b利用海**式,求面積 22樓: ||示例**如下: #include #include int t_style(int a,int b,int c)if(a>c) if(b>c) if(a+b > c) else return -1; }float t_area(int a,int b,int c)int main() if(t_style(x,y,z) > 0)printf("三角形面積= %.2f\n",t_area(x,y,z)); return 0; }示例執行結果: 程式設計題:編寫程式輸入三角形的3條邊長,計算並輸出三角形的面積。 23樓:冰封月 一、程式分析 三角形面積海**式:√[ p ( p - a ) ( p - b ) ( p - c ) ] 。其中 p = (a + b + c) / 2 。a、b、c分別是三角形的三邊長。 二、根據三角形面積計算公式用if語句編寫程式如下: #include "stdio.h" #include "math.h" int main(void) else printf("******** does not exist!\n"); printf("the area of ******** is:%f\n", area); return 0; 擴充套件資料:還可以使用switch語句計算三角形的面積,編寫程式如下#include "stdio.h" #include "math.h" int main(void) return 0;} 24樓:杜哥是個小天才 #include #include int main() 拓展資料c語言是一門通用計算機程式語言,應用廣泛。c語言的設計目標是提供一種能以簡易的方式編譯、處理低階儲存器、產生少量的機器碼以及不需要任何執行環境支援便能執行的程式語言。 儘管c語言提供了許多低階處理的功能,但仍然保持著良好跨平臺的特性,以一個標準規格寫出的c語言程式可在許多電腦平臺上進行編譯,甚至包含一些嵌入式處理器(微控制器或稱mcu)以及超級電腦等作業平臺。 25樓: #include main() 26樓:匿名使用者 fire歷史 的程式有寫問題 我稍微改了下#include #include void main(void) if(a+c <=b) if(b+c <=a) s=(a+b+c)/2; t=s*(s-a)*( s-b)*(s-c); area=sqrt(t); printf("面積 s=%3.2f\n",area);//保留兩位小數 一堆小數太難看 printf("周長 c=%3.2f\n",a+b+c); printf("想再來一遍嗎? n/y "); fflush(stdin); again = getchar(); }while( again =='y'||again == 'y'); }另外,虛機團上產品**,超級便宜 27樓:匿名使用者 #include #include void main() 後面的!是幹嘛的?如果有!就用for迴圈然後拼接成一個字串!簡單而高效!n的值不能超過13,否則會因為資料溢位而回導致結果錯誤。答 include int main printf d n sum return 0 include stdio.h main printf n f sum getch i... include define pai3.1415926 void main 因為方便,我就把r,c,s定義為int型別了,你可以根據你的需要修改型別 那用 語言編寫一個程式從鍵盤輸入圓的半徑計算該圓的周長面積。並輸出 include void main include include include... include extern int system const char int main j 97 for i 26 i 52 i printf please input a word n n gets input for i 0 input i 0 i for i 0,j 0 i 52 i pr...C語言編寫程式求1! 2! 3n ,n由鍵盤輸入
那用c語言編寫程式從鍵盤輸入圓的半徑計算該圓的周長面積
C語言編寫程式,從鍵盤輸入若干個英文字母,並統計各字母出現的次數