c语言编写计算矩形面积和周长
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/13 00:12:27
#include#definePI3.1415926doublearea(doubler){returnPI*r*r;}doubleperimeter(doubler){return2*PI*r;}i
#includeintmain(){floatr,s,l;scanf("%f",&r);s=3.14*r*r;l=2*3.14*r;printf("s=%f,l=%f\n",s,l);return0;
#include#includeusingnamespacestd;intmain(){constfloatPI=3.1416f;floatr;cin>>r;floatc=2*PI*r;fl
#includedoublecalRectArea(doubledWidth,doubledHeigh){returndWidth*dHeigh;}voidmain(){doublea,b,mul;s
#includeintmain(){doublewidth;doubleheight;printf("请输入矩形的长:");scanf("%lf%*c",&height);printf("请输入矩形的
voidmain(){floatr,s,l;floatpi=3.1415;printf("输入一个圆的半径:\n");scanf("%f",&r);if(
intarea(intx,inty){returnx*y;}intgri(intx,inty){return2*(x+y);}
#include<stdio.h>double zc(double x, double y){ ret
这个貌似你对scanf和printf的用法没搞清楚,正确写法应该是scanf("%f,%f",&a,&b);(&取地址符,表示把值存放在该地址)printf("2*(a+b)=%f,a*b=%f",c
#include <stdio.h>#include <math.h>//double sin(double x);#define&nb
代码大致思路没有错.不过,采用浮点型数据的时候,输入输出的格式不是用%d(整数),而是用%f所以,把你的代码里,%ld改成%lf,%d改成%f,%.6ld改成%.6lf就可以了.另外,面积公司改成ar
#include "stdio.h"double mianji(double x,double y){ r
p=(a+a+a)/2.0;转换成浮点型再把结果赋给p
.就知道一个周长,怎么求面积啊?N种可能啊满意请采纳
#include#definePremeter(a,b)2*(a+b)#defineArea(a,b)a*bintmain(){doublea,b;printf("请输入矩形的长和宽:\n");sca
#include"stdio.h"//面积doublearea(doublelen,doublewid){returnlen*wid;}//周长doublecircle(doublelen,doubl
#includevoidmain(){doubler,s,l;printf("请输入圆的半径\n");scanf("%lf",&r);s=3.14159*r*r;l=2*3.14159*r;print
#includeintmain(){intlength,width,perimeter;printf("长:");scanf("%d",&length);printf("宽:");scanf("%d"
#include"stdio.h"#definePI3.141592653//定义πintmain(void){floatC,A,V,r;printf("请输入半径:");//提示输入scanf("%
m=2a+2b;应该改成m=2*a+2*b;程序中2a,2b是不允许的,没有意义的.