How to decrease size of c++ source code? [closed]
- by free0u
For example
#include <iostream>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cout << i;
}
return 0;
}
Decrease:
#include <fstream>
int main() {
std::ifstream y("input.txt");
std::ofstream z("output.txt");
int n, i = 0;
y >> n;
while(i < n)
z << i++;
exit(0);
}
What's about "fstream"?
std::fstream y("input.txt"), z("output.txt")
It's amazing but output is not correct.)
"output.txt" isn't remaking. Output is writing from begin of file.
How to decrease code?
Just for fun)