codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <string> #include <vector> #include <fstream> #include <sstream> #include <iostream> using namespace std; int main(){ //это эммуляция файла string data = "1 2 3\n" "4 5 6\n" "7 8 9"; string line; float fValue = 0; vector< vector< float > > matrix; stringstream ifs(data);//заменить на fstream.open while( ifs>>line ) { vector< float > fLine; stringstream ss(line); while( ss>>fValue ) fLine.push_back(fValue); matrix.push_back(fLine); } for( size_t i = 0; i < matrix.size(); i++ ) { for( size_t j = 0; j < matrix[i].size(); j++ ) cout<<matrix[i][j]<<" "; cout<<endl; } return 0; }
Private
[
?
]
Run code
Submit