The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C++ Code
Posted by: jaemyeong Eo | September 12, 2010 @ 10:51pm
C++ Code
[
Download
]
#include <string> #include <vector> #include <iostream> #include <fstream> using namespace std; class player { private: string last_name; string first_name; vector <int> score; public: string get_last_name(); void set_last_name( string n_l_name); string get_first_name(); void set_first_name ( string n_f_name); vector <int> get_score(); void set_score ( vector <int> n_score); } string player::get_last_name() { return last_name; } void player::set_last_name( string n_l_name) { last_name = n_l_name; } string player::get_first_name() { return first_name; } void player::set_first_name( string n_f_name) { first_name = n_f_name; } vector <int> player::get_score() { return score; } void player::set_score( vector< int > n_score) { for ( int i=0; i< n_score.size() ;i++) { score.push_back( n_score[i]); } } int main( int argc, char* argv[]) { //Intput the file using command line argv[1]. ifstream read_file(argv[1]); if ( !read_file ) { cerr << "Can't open " << argv[1] << " to read \n"; exit(1); } string temp_last_name; string temp_first_name; int temp_score; vector < int > vec_temp_score; vector < player > vec_players; player temp_player; while ( !read_file.eof()) { read_file >> temp_first_name >> temp_last_name; //read_in the last, first names. for ( int i=0; i< 20;i++) // loop through the integers(scores) and read into the vector. { read_file >> temp_score; vec_temp_score.push_back(temp_score); } temp_player.set_last_name( temp_last_name); temp_player.set_first_name( temp_first_name); temp_player.set_score( vec_temp_score); vec_players.push_back(temp_player); } //Out file the output using command line argv[2]. ofstream out_file(argv[2]); if ( !out_file ) { cerr << "Can't open " << argv[2] << " to read \n"; exit(1); } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.48 / 8
44 Votes