當前位置:首頁 » 編程軟體 » 編程形狀

編程形狀

發布時間: 2022-10-15 19:59:42

❶ 關於c語言中判斷三角形形狀的編程

很好啊,有錯嗎?
如果有錯,也就是int main()沒有返回值,你可以加個return 0; 也可以改成void main();
另外屏幕輸入邊長的時候,注意要用「3,3,3」;「2,3,4」這樣的格式。這個應該不用提示吧。

❷ c語言編程,判斷三角形形狀,

你的輸入錯誤了吧?你限定的輸入格式是用逗號隔開的
輸入例子一13,13,13
例子二13,23,13

❸ 用java語言編程,求多種形狀的面積之和

public Interface Shape
{ private double area;

public abstract double getArea();
}

然後對於各種形狀分別定義,比如:
public Circle implements Shape
{ private double radius:

public Circle(double radius)
{ this.radius=radius;
this.area=radius*radius*Maths.PI;
}

public double getArea()
{ return area;
}
}

public Rectangle implements Shape
{ private double height;
private double width;

public Rectangle(double height,double width)
{ this.height=height;
this.width=width;
this.area=height*width;
}

public double getArea()
{ return area;
}
}

等等。

用的時候分別定義各個形狀的具體參數。
求面積的和可以用
Object[] shapes;
double sum=0.0;
for(int i=0;i<shapes.length;i++)
sum+=(Shape)shapes[i].getArea();

❹ 用c語言編程判斷三角形的形狀

#include<stdio.h>
bool equl(float a,float b)
{
if(a==b)
return true;
else
return false;
}
bool alleq(float a,float b,float c)
{
if(a==b&&b==c&&c==a)
return true;
else
return false;
}
void juge(float a,float b,float c)
{
if(a+b<=c)
{
printf("non-triangle.\n");
}
else if(b+c<=a)
{
printf("non-triangle.\n");
}
else if(a+c<=b)
{
printf("non-triangle.\n");
}
else
{
if(equl(a,b)||equl(b,c)||equl(a,c))
{
if(alleq(a,b,c))
printf("equilateral triangle.\n");
else
printf("isoceles triangle.\n");
}
else
printf("triangle.\n");
}
}
void main()
{
float a,b,c;
printf("�0�5�0�5�0�8�0�1�0�6�0�5�0�6�0�5�0�5�0�5�0�4�0�1�0�8�0�2�0�6�0�5�0�0�0�1±�0�8\n");
scanf("%f,%f,%f",&a,&b,&c);
if((a<=0)||(b<=0)||(c<=0))
{
printf("non-triangle.\n");
}
else
{
juge(a,b,c);
}
}很久沒有寫C了,可能有語法錯誤,你自己調一下。希望可以幫到你

❺ c/c++編程輸出菱形形狀的星 星圖形;菱形圖形的大小由鍵盤輸入的行數決定,求大神幫忙,要說明....

#include<stdio.h>
intmain()
{
introw,i,j,N;
scanf("%d",&N);//輸入大小
row=1;
while(row<=N)/*前N排星號*/
{
for(i=1;i<=N-row;i++)
printf("");
for(j=1;j<=2*row-1;j++)
printf("*");
printf(" ");
row++;
}
row=1;

while(row<=N-1)/*後N-1排星號*/
{
for(i=1;i<=row;i++)
printf("");
for(j=1;j<=2*(N-row)-1;j++)
printf("*");
printf(" ");
row++;
}

return0;
}

❻ 如何使用GL庫在unity3d游戲編程中繪制形狀

打開unity,新建一個工程文件。

點擊菜單欄中的GameObject->Creat Other,從彈出的數據框中可以選擇Cube、Sphere等簡單的幾何模型。點擊所需的模型後就會在Scene窗口中看到創建好的模型。

可以在Inspector窗口中對其進行操作,加減組件等。

點擊菜單欄中的File->Save Scene將場景進行保存。在彈出的數據框中選擇存放路徑、填寫Scene名稱等。

點擊保存後就可以看到建立好的Unity文件了。

❼ ★☆如何用這兩個符號 編程一個心的形狀

★☆可已通過搜狗特殊符號得到
新的形狀,則需要(比較笨的方法是排列組合試試)演算法的實現了;
建議排列組合試試即可;先【排一個曉得心行即可;

❽ C語言怎麼編程判斷三角形的形狀

代碼如下:

#include <stdio.h>

#include <stdlib.h>

#defineEPSINON1e-3
#defineABS(a)(((a)>0)?(a):(-a)) //?:不支持表達式嵌套
#define ZERO(x)((x)>-EPSINON && (x)<EPSINON)
#define MAX(a,b)(((a)>(b))?(a):(b))
#define MIN(a,b)(((a)<(b))?(a):(b))
float a, b, c;
float max, mid, min;
char input_err_flag = 0;
char judge_err_flag = 0;
int equal(float a, float b)
{
float tmp;
tmp = a - b;
tmp = ZERO(ABS(tmp));
return tmp;
}
void input(void)
{
a = b = c = 0;
printf("輸入三條邊的值:");
scanf("%f %f %f",&a, &b, &c);
if(!(a>0) || !(b>0) || !(c>0))
{
input_err_flag = 1;
}
}
void sort(void)
{
max = MAX(MAX(a,b),c);
min = MIN(MIN(a,b),c);
if(MAX(a,b) < c)
mid = MAX(a,b);
else
mid = MAX(MIN(a,b),c);
}
void judge(void)
{
float max_square, mid_square, min_square, tmp;
if(max >= (mid+min))
{
judge_err_flag = 1;
}
else
{
max_square = max * max;
mid_square = mid * mid;
min_square = min * min;
tmp = mid_square + min_square;
if(equal(mid,min) || equal(max, mid))
{
if(equal(mid, min))
{
if(mid == max)
puts("等邊三角形。");
else if(equal(max_square, tmp))
puts("等腰直角三角形。");
else if(max_square < tmp)
puts("等腰銳角三角形。");
else
puts("等腰鈍角三角形。");
}
else
{
if(equal(min, mid))
puts("等邊三角形。");
else
puts("等腰銳角三角形。");
}
}
else if(equal(max_square, tmp))
puts("直角三角形。");
else if(max_square < tmp)
puts("銳角三角形。");
else
puts("鈍角三角形。");
}
}
int main(void)
{
char cs, ch;
do
{
input();
sort();
judge();
if(input_err_flag)
{
input_err_flag = 0;
while((cs=getchar())!=' ' && (cs=getchar())!=EOF);
printf("輸入錯誤,a b c必須大於零,是否新輸入(y/n):");
}
else if(judge_err_flag)
{
judge_err_flag = 0;
while((cs=getchar())!=' ' && (cs=getchar())!=EOF);
printf("組不成三角形,是否重新輸入(y/n):");
}
else
{
while((cs=getchar())!=' ' && (cs=getchar())!=EOF);
printf("是否再輸入一組數據(y/n):");
}
ch = getchar();
}
while(ch=='y' || ch=='Y' || ch==' ');
puts("Goodbye!");
return 0;
}

❾ C語言,怎麼編程判斷三角形的形狀

從小到大排序:a<=b<= c

如果a+b>c,是三角形,否則不是三角形[三角形兩邊之和大於第三邊]

三邊相等:等邊三角形
兩邊相等:等腰三角形
a*a+b*b=c*c:直角三角形

熱點內容
主伺服器ip地址 發布:2025-05-18 02:46:29 瀏覽:854
電腦配置太低玩不了絕地求生怎麼辦 發布:2025-05-18 02:38:39 瀏覽:795
存儲過程怎麼出錯了 發布:2025-05-18 02:37:16 瀏覽:367
32寸演算法 發布:2025-05-18 02:22:14 瀏覽:743
寶塔資料庫備份 發布:2025-05-18 02:14:18 瀏覽:192
安卓商店下載的光遇是什麼服 發布:2025-05-18 02:13:38 瀏覽:31
網頁挖礦源碼 發布:2025-05-18 02:13:34 瀏覽:307
centosftp伺服器設置參數 發布:2025-05-18 02:12:55 瀏覽:216
賬號密碼保存在瀏覽器哪裡 發布:2025-05-18 01:56:43 瀏覽:833
ftp不輸入密碼 發布:2025-05-18 01:54:27 瀏覽:671