[問題] 讀檔寫入結構
之前問過一次了還是不太懂= =
我要讀一筆資料1.txt 4
3 1000
7 999
-10 998
80 500
2
19 1000
7 0
存成2個多項式 struct結構 要做linked list
4 2->項數 3 7...->指數 1000 999->係數
我該怎麼寫? 目前只能讀檔列印出來= =
存進去的動作要怎麼寫?
謝謝
#include <iostream>
#include <fstream>
using namespace std;
struct Polynomials
{
int exponents;
int coefficients;
struct poly* next;
};
int main()
{
ifstream fin("1.txt");
cout << "輸入"<<endl;
if(!fin){ cout << "讀檔失敗" << endl; } // 檢查讀檔成功與否
while (fin.good())
cout << (char) fin.get();
fin.close(); // 關閉檔案
system("pause");
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.232.0.235
→
07/29 15:09, , 1F
07/29 15:09, 1F
→
07/29 15:46, , 2F
07/29 15:46, 2F
→
07/29 15:49, , 3F
07/29 15:49, 3F
→
07/29 17:33, , 4F
07/29 17:33, 4F
→
07/29 18:49, , 5F
07/29 18:49, 5F
→
07/29 18:50, , 6F
07/29 18:50, 6F
→
07/29 21:57, , 7F
07/29 21:57, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章