Alex Origami Squares

在这里插入图片描述

#include <stdio.h>
int main()
{
    
    
    freopen("alex.in", "r", stdin);
    freopen("alex.out","w",stdout);
      double  h, w, t, r;
      scanf("%lf %lf",&h, &w);
      if(w>h)
      {
    
    
          t = w, w = h, h = t;
      }
      if(w>=2.0/3*h)
      {
    
    
          r = w/2.0;
      }
      else if(w>=1.0/3*h)
      {
    
    
          r = h/3.0;
      }
      else
        r = w;
      printf("%.6lf\n",r);
    return 0;
}

freopen函数用法
1.freopen是被包含于C标准库头bai文件<stdio.h>中的du一个函数,用于重定向输入输出流。该函数可zhi以在不dao改变代码原貌的情况下改变输入输出环境
2.函数名:freopen
函数,以指定模式重新指定到另一个文件。模式用于指定新文件的访问方式。
头文件:stdio.h
C89函数声明:
*FILE freopen( const char filename, const char mode, FILE stream );
C99函数声明:
FILE freopen(const char * restrict filename, const char * restrict mode, FILE * restrict stream);
形参说明:
filename:需要重定向到的文件名或文件路径。
mode:代表文件访问权限的字符串。例如,"r"表示“只读访问”、"w"表示“只写访问”、"a"表示“追加写入”。
stream:需要被重定向的文件流。
返回值:如果成功,则返回该指向该输出流的文件指针,否则返回为NULL。

猜你喜欢

转载自blog.csdn.net/a675891/article/details/107701333