freopen重定向输入

#include <bitsstdc++.h>
using namespace  std;
int main()
{
    freopen("C:\Users\dcf\Desktop\txt.txt","r",stdin);
    int n,mx=0;
    while(cin>>n)
    {
        if(n>mx)
            mx=n;
    }
    cout<<mx<<endl;
    return 0;
}

freopen 可代替大量的数据输入

原文地址:https://www.cnblogs.com/cynthia-dcg/p/6689421.html