#include<stdio.h>#include<math.h>intmain(){double x, y, s;scanf("%lf%lf",&x,&y);
s =sqrt(x +2* y)-exp(3* x)+fabs(x);printf("%lf\n", s);return0;}
实验02(02)fabs
已知双精度实型变量 x=1.5,编程计算下列表达式的值:
1/2sin25(度)+x^2cos30(度)
说明:此处 x^2 表示 x 的平方,PI 值取 3.1415926
x 的值从键盘输入
注意:sin25、cos30:度数必须转换为弧度
输入描述
输入 x 的值
输出描述
表达式的值
输入样例
1.5
输出样例
2.159866
#include<stdio.h>#include<math.h>#define PI 3.1415926intmain(){double x, y;scanf("%lf",&x);
y =1.0/2*sin(25.0/180* PI)+ x * x *cos(30.0/180* PI);printf("%lf\n", y);return0;}
#include<stdio.h>#include<math.h>intmain(){double x1, x2, x3, y1, y2, y3, S, A, a, b, c, p;scanf("%lf%lf\n",&x1,&y1);scanf("%lf%lf\n",&x2,&y2);scanf("%lf%lf",&x3,&y3);
a =sqrt(pow((x1 - x2),2)+pow((y1 - y2),2));
b =sqrt(pow((x1 - x3),2)+pow((y1 - y3),2));
c =sqrt(pow((x2 - x3),2)+pow((y2 - y3),2));
A = a + b + c;
p =1.0/2*(a + b + c);
S =sqrt(p *(p - a)*(p - b)*(p - c));if(a + b > c && a + c > b && b + c > a){printf("能构成三角形,周长为:%.3lf,面积为:%.3lf\n", A, S);}else{printf("这三点不能构成三角形!\n");}return0;}
#include<stdio.h>intmain(){double x, y;scanf("%lf",&x);if(x >15){
y =2.5* x -17.5;}elseif(x >0){
y =4.0* x /3;}elseif(x ==0){
y =0;}printf("本月应支付水费:%.2lf\n", y);return0;}