I was learning from the USACO Portal when I came across the following template for submitting solutions., in C++. It was like this.
I’m confused. It uses fin and fout to input a and b. I’ve been using cin and cout till now, so if I use the USACO training pages, am I supposed to uses fout in place of cout always?
@anon21889647
Well, fout and fin are used to define input and output from a file. Really you could use anything as they are user defined names.
#include <fstream>
ifstream fin ("filename.in"); //you could use anything instead of fin...
// It is user defined, use whatever you want.
// ifstream cfin ("filename.in") would get the job done in the same
//manner excpet now you would write cfin >> a >> b;
ofstream fout ("filename.out") ;
int a, b;
fin >> a >> b;
fout << a+b << "\n"
//This code snippet can be used to read input from filename.in and give output to
// filename.out