用cout cin替换printf()和scanf()

2024-12-23 07:57:47
推荐回答(2个)
回答1:

main前面加上
#include
using namespace std;

相应的改为 cout<<"please input 3 sides of one triangle:\n";
cin>>a>>b>>c;
cout<<","<cout<<"area of truangle is "<

回答2:

#include
#include
#include
#include
using namespace std;

int main()
{
float a,b,c,s,area;
cout<<"please input 3 sides of one triangle:"< cin>>a>>b>>c;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
cout.setf(ios::fixed);
cout.precision(2);
cout<<"a="< cout.precision(5);
cout<<"area of triangle is"< return 0;
}