test.in讀取資料test.out
freopen(檔案名稱,讀或寫,當作哪個資料流);"D:\\Example\\test.in"或是"test.in"
"r"表示讀(read),"w"表示寫(write)
freopen("a.in","r",stdin)a.in讀取檔案,用stdin來操作#include<fstream>fstream f;
f.open("test.in",ios::in);讀檔f.open("test.out",ios::out);寫檔
closeendlfreopen,fopen花了50秒fstream使用endl花了39秒fstream使用'\n'花了15秒
| 5 | 4 | 6 | 3 | 1 |
| 5 | 4 | 6 | 3 | 1 | 2 |
| 5 | 4 | 6 | 3 | 2 | 1 |
| 5 | 4 | 6 | 3 | 2 | 1 |
| 5 | 4 | X | 3 | 2 | 1 |
| 5 | 4 | 1 | 3 | 2 |
| 5 | 4 | 3 | 1 | 2 |
