当前位置:网站首页>Enter the triangle side length and calculate the area
Enter the triangle side length and calculate the area
2022-07-23 12:33:00 【xiq1212】
Enter the triangle side length , Find the area
The formula :s = 1/2(a+b+c);area = √s*(s-a)(s-b)(s-c)
This code looks simple , But there are several corresponding formulas “ Small pit ”.
1. The first thing to note is
‘/’ to be divisible by —— integer , If your actual calculation result is a ratio 1 Small integers , The computer will automatically fetch you 0. Here you can force the result of the operation to be converted into , Single precision or double precision floating-point data .
s = 1/2(a+b+c);area = √s*(s-a)*(s-b)*(s-c);
2. The second is the quotation here sqrt Root function
So we need to link from the beginning math library .
#include<math.h>
3. Full code
#include <stdio.h>
#include <math.h>
int main(int argc, const char *argv[])
{
int s,a,b,c;
printf(" Please enter the triangle side length :\n");
scanf("%d%d%d",&a,&b,&c);
if(a+b<c||a+c<b||b+c<a)
{
printf("err\n");
return -1;
}
else if(a<0||b<0||c<0)
{
printf("err\n");
return -1;
}
else
{
s=(double)1/2*(a+b+c);
s=sqrt(s*(s-a)*(s-b)*(s-c));
printf(" The area of the triangle is :%d\n",s);
}
return 0;
}
4. Running results :

边栏推荐
- Uni native plug-in development -- Youmeng one click login
- 对字符串函数的使用和理解(2)
- Interpretation of the paper: "bert4bitter: a basic model for improving bitter peptide prediction based on transformer (BERT) bidirectional encoder representation"
- NLP natural language processing - Introduction to machine learning and natural language processing (I)
- 使用PyOD来进行异常值检测
- A hundred schools of thought contend at the 2021 trusted privacy computing Summit Forum and data security industry summit
- 单片机学习笔记7--SysTick定时器(基于百问网STM32F103系列教程)
- 高电压技术重点知识整理
- 博客搭建五:图床选择
- NVIDIA NVIDIA released H100 GPU, and the water-cooled server is adapted on the road
猜你喜欢

博客搭建五:图床选择

ARM架构与编程6--重定位(基于百问网ARM架构与编程教程视频)

【AUTOSAR COM 1.通信协议栈介绍】

Interpretation of the paper: develop and verify the deep learning system to classify the etiology of macular hole and predict the anatomical results

利用pycaret:低代码,自动化机器学习框架解决回归问题

高等代数知识结构

2021 TOP10 development trend of information science. Deep learning? Convolutional neural network?

单片机学习笔记8--按键和外部中断(基于百问网STM32F103系列教程)

ARM架构与编程1--LED闪烁(基于百问网ARM架构与编程教程视频)

Data analysis of time series (III): decomposition of classical time series
随机推荐
[physical layer of CAN bus] 1. Content sharing of can/canfd sampling points
【分清楚常量指针与指针常量 Const int *与Int * Const的含义与用法】
钢结构基本原理题库
时间序列的数据分析(三):经典时间序列分解
高分子物理考研概念及要点、考点总结
【AUTOSAR CanDrive 2.了解通信Hoh、CanId与PduID的Mapping关系】
深度卷积生成对抗网络
高电压技术试题及答案
Analyze the pre integration of vio with less rigorous but logical mathematical theory
硬件知識1--原理圖和接口類型(基於百問網硬件操作大全視頻教程)
【AUTOSAR COM 2.通信协议栈进阶介绍】
钢结构复习题
【存储器了解 RAM flash和eeprom存储器的区别和作用】
[AUTOSAR com 1. introduction to communication protocol stack]
Interpretation of the paper: DNA enhancer sequence recognition transformer structure based on Bert and two-dimensional convolutional neural network
大小写字母转换
Tencent cloud client command line tool tccli main process analysis
Interpretation of the paper: "deep-4mcw2v: sequence based predictor for identifying N4 methylcytosine (4mc) sites in E. coli"
Green data center: comprehensive analysis of air-cooled GPU server and water-cooled GPU server
Interpretation of the paper: "i4mc deep: intelligent prediction of N4 methylcytosine sites using deep learning methods with chemical properties"