数据录入的代码问题
程序代码:
#include <vector> #include <fstream> #include <iostream> #include <cmath> struct foo { int user, item, rating, v4; }; struct cinema { int item,rating; }; int main() { int i = 1; cinema c1; std::vector<cinema> v1; std::vector< std::vector<cinema> > base; //数据录入 std::ifstream infile1("base"); if( infile1 ) { for( foo f; infile1>>f.user>>f.item>>f.rating>>f.v4; ) { if( f.user = i) { c1.item = f.item; c1.rating = f.rating; v1.push_back( c1 ); } else { i += 1; base.push_back( v1 ); } } } std::cout<<base[1][5].item; return 1; }
[ 本帖最后由 yqjohn 于 2013-2-14 10:01 编辑 ]