私の入力は行列とその次元です!私はこのコードを持っていますが、私は非常に大きな問題のために入力として自分のコードにtxtファイルを使いたいです!私はそれをどうすればいいのか誰にでも教えてくれますか?私は入力としてtxtファイルをC++で使用する方法
あなたが行うことができます int main() {
int i = 0, H = 0;
cout << "Enter no of rows of the matrix k5";
cin >> i;
cout << "Enter no of columns of the matrix";
cin >> H;
int A[i][H] = { };
int p = 0, q = 0;
while (p < i) {
while (q < H) {
cout << "Enter the" << p + 1 << "*" << q + 1 << "entry";
cin >> A[p][q];
q = q + 1;
}
p = p + 1;
q = 0;
}
return 0;
}
_a大きな問題は何ですか?基本的に 'std :: cin'の入力を' std :: ifstream'の入力で置き換えます。 – user0042
私は、手で行列の要素を入力することができないことを意味しました!私はファイルを使いたい!詳細を教えてください。 – shere
http://en.cppreference.com/w/cpp/io/basic_ifstream – user0042