编写一个C程序,从键盘上输入矩形的长和宽,屏幕上显示对应的矩形周长和面积

如题所述

第1个回答  2011-03-20
#include<stdio.h>

int main()
{
double a,b ;
cin>>a>>b ;
printf("S=%f,C=%f",a*b,(a+b)*2) ;
return 0 ;
}追问

不行,C程序的啊。。。这个不好使啊。。。有4个错误

追答

把cin>>a>>b ;
换成scanf("%f%f",&a,&b) ;

不好意思,习惯了C++了。。。

本回答被提问者采纳
第2个回答  2011-03-20
#include<stdio.h>
main()
{ double a,b,s,c;
scanf("%f%f",&a,&b);
printf("s=%f,c=%f\n",a*b,(a+b)*2) ;
}
第3个回答  2011-03-23
#include<stdio.h>
main()
{ double width,height,area,girth;
printf("Please Input height and width:")
scanf("%f%f",&height ,&width);
printf("area=%f,girth=%f\n",width*height ,(width+height )*2) ;
getch();
}
相似回答