First thing, don't panic, read your code and actually know what it is doing.
To check if all numbers in a column are negative, you need to loop over an entire column first while having something, preferably a boolean, to tell you if any of them is not negative.
For example: create a flag that defaults to true.
bool allNegative = true;
for ( int i =0; i < (sizeof(matrix[0])/sizeof(int)); i++)
{
if(matrix[i][0] > 0) allNegative = false; // change the flag to indicate that it is not all negative
}
Then what you want to do is if the flag is still true, loop that column again to just copy and paste all this code for each row to output that column to a txt file.
out<<setw(5)<<A[i][j]<<" ";
out<<endl;
EDIT: thanks to comment, I have changed the syntax error.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…