Explorar el Código

using <iomanip> to format output

webturing hace 4 años
padre
commit
6f0d55a4b1
Se han modificado 1 ficheros con 2 adiciones y 5 borrados
  1. 2 5
      L.cpp

+ 2 - 5
L.cpp

@@ -2,9 +2,6 @@
 
 using namespace std;
 
-void fout(double x, int scale = 6) {
-    cout << setiosflags(ios::fixed) << setprecision(scale) << x << endl;
-}
 
 int main(int argc, char const *argv[]) {
     double U, D, H, slope, area, perimeter;
@@ -12,7 +9,7 @@ int main(int argc, char const *argv[]) {
     area = (U + D) * H / 2;
     slope = hypot((D - U) / 2, H);
     perimeter = U + D + 2 * slope;
-    fout(area, 2);
-    fout(perimeter, 2);
+    cout << fixed << setprecision(2) << area << endl;
+    cout << fixed << setprecision(2) << perimeter << endl;
     return 0;
 }