留言
|
主題: |
關於比賽時流程控制問題 |
留言人: |
Penut花生 |
留言日期: | 2010/11/20 上午 02:08:09 |
留言IP: | 123.204.108.156 |
留言內容: |
如果以去年的一定中樂透來講: /***/ #include <iostream> #include <fstream> using namespace std; int main() { int a,b; ifstream fin("pc.in"); ofstream fout("pc.out"); fin >> a >> b; while(a!=0 && b!=0) { if(a%2==b%2) cout << "Win" << endl; else cout << "Loss" << endl; fin >> a >> b; } } /***/ 我的重點是 開關檔方式一樣如上嗎? 還是用while(cin >> a >> b)之類的其他方式? |
目前回應文章
|
回覆人 | 主題 | 回覆日期 |
skipper | Re:: | 2010/11/20 上午 09:44:14 |
Penut花生 | Re:: | 2010/11/20 下午 09:22:07 |
Ming Tsay | Re:關於比賽時流程控制問題: | 2010/11/21 下午 02:36:51 |
主題: | |
暱稱: | skipper |
留言日期: | 2010/11/20 上午 09:44:14 |
留言IP: | 140.112.7.*** |
內容: | 您好: 1. 今年的比賽環境跟去年略有不同, 裁判程式會從標準輸入送入測資到您撰寫的程式, 然後從標準輸出取得您的程式的輸出. 您的程式不需要做檔案的輸入輸出, 直接從stdin (cin)讀取測試資料, 寫到 stdout (cout) 即可. 2. 如果你自己有做測試資料(從題目上copy下來), 假設您命名為pa.in, (1) 在PC^2 的環境用Test功能, PC^2會叫您選一個檔案, 它就會幫您將這個檔案轉送到您的程式的標準輸入. (2) 在命令列可以用 IO Redirtion 的方式 pa.exe < pa.in > pa.out fstream 是 Penut花生 said---- >如果以去年的一定中樂透來講: > >/***/ >#include <iostream> >#include <fstream> >using namespace std; >int main() >{ > int a,b; > ifstream fin("pc.in"); > ofstream fout("pc.out"); > fin >> a >> b; > while(a!=0 && b!=0) > { > if(a%2==b%2) cout << "Win" << endl; > else cout << "Loss" << endl; > fin >> a >> b; > } >} >/***/ > >我的重點是 開關檔方式一樣如上嗎? >還是用while(cin >> a >> b)之類的其他方式? end of Penut花生 said---- |