入力からスペースを削除するにはどうすればよいですか?? 整数配列です。入力は次のようになります。
5 6 2 9
3 1 11 4
整数として受け取る必要があります。次に、バブルソートを使用して並べ替えます。問題は、次のような出力が得られることです。9 8 7 4 2 1 -858993460 -858993460 -858993460 -858993460
class inout
{
public : 
    int i[10];
    inout()
    {
    }
    void read()
    {
        ifstream inClientFile( "input.txt", ios::in );
        if ( !inClientFile )
            {
            cerr << "File could not be opened" << endl;
            exit( 1 );
            }
        int n=0;
        while (inClientFile >> i[n])
        {
            n++;
        }
        cout << " Data read complete" << endl;
    }
    void write()
    {
       ofstream outClientFile( "output.txt", ios::out ); 
       if ( !outClientFile ) {  
          cerr << "File could not be opened" << endl;
          exit( 1 );
       } 
        int n=0;
        for (int l=0 ; l < 10 ; l++)
        {
          outClientFile << i[l] << " " ;
        }   
        cout << " Data Write complete"  << endl;
    }
    void sortData(int asc )
    {
        int pos=0;
        int temp;
        temp = i[0];
        // asending 
        if (asc == 1)
        {
        for (int p = 0; p < 10 ; p ++ )
        {
        int pos=p;
        int temp2,temp = i[p];
            for (int j = p+1 ; j < 10 ; j ++ )
            {
                if (pos == p)
                {
                    if (i[p] > i[j])
                    {
                        pos = j;
                        temp = i[j];
                    }
                }
                else {
                    if (i[pos] > i[j])
                    {
                        pos = j;
                        temp = i[j];
                    }
                }
            }
            temp2 = i[pos];
            i[pos] = i[p];
            i[p] = temp2;
        }
    }
    else
    {
        for (int p = 0; p < 10 ; p ++ )
        {
        int pos=p;
        int temp2,temp = i[p];
            for (int j = p+1 ; j < 10 ; j ++ )
            {
                if (pos == p)
                {
                    if (i[p] < i[j])
                    {
                        pos = j;
                        temp = i[j];
                    }
                }
                else {
                    if (i[pos] < i[j])
                    {
                        pos = j;
                        temp = i[j];
                    }
                }
            }
            temp2 = i[pos];
            i[pos] = i[p];
            i[p] = temp2;
        }
    }
    }
};
int main()
{
    int d;
    inout x;
    x.read();
    cout<<"Press 1 to sort into ascending order"<<endl<<"Press any other key to sort into descending order"<<endl;
    cin>>d;
    x.sortData(d);  
    x.write();
}