如何把样例从文件中输入程序
#include<iostream> #include<cmath> #include<cstdio> #include<algorithm> #include<string> #include<cstring> using namespace std; int main() { freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); int a; cin>>a; cout<<a*a; return 0; }
提前在程序所在的文件夹中创建in.txt和out.txt