Welcome   HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online
Home
FAQs
Problem Set
Practices
Online Contests
Major Exercises
OI Special
Judgement
Submit
Online Status
User Ranklist
Users
Register new
Login
Web Links
Hunan Normal University
College of Information Science and Engineering
三角形的面积
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 83, Accepted users: 64
Problem 11291 : No special judgement
Problem description
  读入三角形三边的边长a,b,c,输出它的面积。

Input
  有多组测试数据。输入的第一行是整数T(0
Output
  对应每组输入,输出一行该三角形的面积,保留两位小数。如果三条边不能构成三角形,请输出“can't construct a triangle!”。该行不能有其它多余的符号。输出格式具体见样例。

Sample Input
3
3 4 5
3 4 7
3 4 8
Sample Output
S(3,4,5)=6.00
S(3,4,7)=0.00
(3,4,8) can't construct a triangle!
Judge Tips
  可以使用公式:S=sqrt(p(p-a)(p-b)(p-c)),其中p=(a+b+c)/2。
输出固定位数小数点
C++

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
double t=3.123456;
cout <<setiosflags(ios::fixed);
cout<<setprecision(2)<<t<<endl;


return 0;
}

C

#include<stdio.h>

int main()
{
double t=3.123456;
printf("%.2lf",t);

return 0;
}


Problem Source
  UESTC

Submit   Discuss   Judge Status  Problems  Ranklist 

HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online, Version 2010.5.5.final.
Web visits:2111 today,12073160 total, since 2010-05-07