C语言圆的半径
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/22 21:58:45
#includemain(){\x09floatS(floatr);\x09floatr;\x09printf("inputr:");\x09scanf("%f",&r);\x09printf("圆面
#include#definepi3.141592653intmain(){doubler;printf("输入半径:\n");scanf("%lf",&r);printf("周长为:\n");pri
#definePI3.1416//后面不需要;#include"stdio.h"//注意关键字之间要有空格intmain(){floatr,s,c;scanf("%f",&r);c=2*PI*
在输入半径的时候,语句改成scanf("%d",&r);不过你最好将半径定义成float型变量,格式的问题
scanf("%d",&r);
voidmain(){floatr,s,l;floatpi=3.1415;printf("输入一个圆的半径:\n");scanf("%f",&r);if(
#include#definePI3.1415926\x05\x05voidmain()\x05{\x05doubler,s;scanf("%f",&r);s=PI*r*r;\x05printf("A
#difinepi3.14#includevoidmain(){floatR=1.5,L,S;L=2*pi*R;S=pi*R*R;printf("L=%fL,S=%fS\n");}
importjava.util.Scanner;publicclassCircle{ publicstaticvoidmain(String[]args)
拿去慢慢研究吧#includeintmain(void){doubler=3.0,pi=3.14159,s;s=r*r*pi;printf("圆的面积为%lf",s);return0;}
1.#includeintmain(){floatr,s,l,v;printf("请输入半径\n");scanf("%f",&r);s=3.14*r*r;l=2*3.14*r;v=4.0/3.0*3.
#include#defineMianji(x)Pi*r*r#definePi3.1415926intmain(){\x09floatr;\x09printf("请输入半径r:\n");\x09sca
#includeintmain(){doubleR;while(scanf("%lf",&R)!=EOF){printf("%lf\n",R*R*3.14);}return0;}
首先程序是能够编译通过的,只是结果不是你想要的.#defineS(bj)PI*bj*bj修改为#defineS(bj)(PI*(bj)*(bj))doublemianJi;修改为float类型.或者将
#includeintmain(){intr=0;floata=0,l=0;scanf("%d",&r);a=r*r*3.14;l=r*2*3.14;printf("面积:%f,周长:%f",a,l)
#include#includemain(){doublearea,length;doubler=pi=3.1215926area=pi*r*r;length=2*pi*r;}
#includeintmain(void){intr;\x05doublev;//这个变量应该改为double类型r=10;v=4.0f/3.0f*3.14*r*r*r;printf("V:%lf\n
#include"stdio.h"#definePI3.141592653//定义πintmain(void){floatC,A,V,r;printf("请输入半径:");//提示输入scanf("%
#include#include#defindPI3.141592654main(){doublevolume;floatradius;printf("Inputradius:");scanf("%f
#include#definepi3.1415926//宏定义voidmain(){inti;doublearea;for(i=1;i