コードでこの構造体を使用する必要があります。
struct Pair
{
int x,y;
friend bool operator==(Pair a, Pair b)
{
return a.x == b.x && a.y == b.y;
}
friend istream& operator>>(istream& is, Pair& a)
{
is >> a.x >> a.y;
return is;
}
friend ostream& operator<<(ostream& os, Pair a)
{
os << '(' << a.x << ',' << a.y << ')';
return os;
}
};
.txt ファイルを読み取る必要があります。
5 1 1 2 2 3 3 4 4 5 5
7 1 1 2 2 3 3 4 4 4 7 7 4 7 7
8 1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64
このファイルには 3 つの関係があり、それぞれがその関係のペアの数である int で始まり、その数のペアが続きます。次に (eof でない場合) 別の int を読み取り、その数のペアを再度読み取ります。
このデータを構造体ペアに読み込むにはどうすればよいですか?
読んだ後、データが再帰的かどうかなどをテストする必要がありますが、このプロジェクトを開始するのに問題があります。