...

看板TunHua08t317作者 (.........)時間22年前 (2004/03/19 11:25), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
#include <fstream> #include <iostream> #include <cstdlib> #include <conio.h> using namespace std; void get(ifstream& in_stream, ofstream& out_stream); int main() { ifstream fin; ofstream fout; cout << "Begin editing files.\n"; fin.open("original.txt"); if (fin.fail()) { cout << "Input file opening failed.\n"; getch(); exit(1); } fout.open("correct.txt"); if (fout.fail()) { cout << "Output file opening failed.\n"; getch(); exit(1); } get(fin, fout); fin.close(); fout.close(); cout << "End of editing files.\n"; getch(); return 0; } void get(ifstream& in_stream, ofstream& out_stream) { char next; in_stream.get(next); //get first character while (! in_stream.eof()) //detect the end of the input file { if (next=='c') { out_stream.put(next); //ouptput c in_stream.get(next); if (next=='i') { out_stream.put(next); //ouptput i in_stream.get(next); if (next=='n') { out_stream.put(next); //ouptput n in_stream.get(next); //get blank out_stream.put(next); //output blank in_stream.get(next); if (next=='<') { out_stream.put('>'); //correct mistake in_stream.get(next); if (next=='<') { out_stream.put('>'); //correct mistake in_stream.get(next); } } } } else if (next=='o') { out_stream.put(next); //ouptput o in_stream.get(next); if (next=='u') { out_stream.put(next); //ouptput u in_stream.get(next); if (next=='t') { out_stream.put(next); //ouptput t in_stream.get(next); out_stream.put(next); in_stream.get(next); if (next=='>') { out_stream.put('<'); //correct mistake in_stream.get(next); if (next=='>') { out_stream.put('<'); //correct mistake in_stream.get(next); } } } } } } out_stream.put(next); in_stream.get(next); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.219.78
文章代碼(AID): #10McWqmo (TunHua08t317)