提出済み | だらだらしてみる。

提出済み

ifstream infile;
infile.open("input.txt");
ofstream outfile;
outfile.open("output.txt");

while(infile)
{
while(index < max)
{
if(!(infile >> i)) break;
array[index] = i;
infile.get(c);

index++;

if(c == '\n') //if end of line
{
MergeSort(index-1, 0, array, tmp_array); //index-1 = H

int k; //display numbers
for(k = 0; k < (index - 1); k++)
outfile << array[k] << ", ";
// for(; k < index; k++)
// これいらんやんけ。
outfile << array[k] << endl;

index = 0; //reset index
}
}
}


ちゃんと動いた。

if(!(infile >> i)) break;

これが必要だったんだ。

2chのプ板の方に感謝。


// いらないとこ省いて再提出しました。
// due まであと30分だった。
// 見直してよかった。
// 別にあっても構わないけど、無い方がいい。


// 読み込みと表示の関数作って
// mainをほぼ空にしてもいいんだけど
// 面倒なのでやめた。

// ほとんどコピーするだけなのに。
// 150点中の何点でしょうか。

// 点数ついたら教えます。


終わり。