#include "listgen.h" #include "listmain.h" #include #include #include #include #include #include #include using namespace std; class Rng { public: Rng() { srand( time( NULL ) ); } unsigned long operator() (unsigned long n) { return (double(n)*rand()/(RAND_MAX+1.0)); } }; void generate_html() { fstream f; f.open(html_name->value(),fstream::out); int n = teachers->size(); if (f.fail() || (!n)) return; vector g[n]; vector sleft; for (int i=0; isize(); i++) sleft.push_back( *((string*)students->data(i+1)) ); Rng r; random_shuffle(sleft.begin(), sleft.end(), r); for (int i=0; i\n\n\n\t

" <value() <<"

\n"; for (int i=0; i\n\t\t"<< "Group #"<<(i+1)<< ": " << teachers->text(i+1) <<""; for (int j=0; j"<< g[i][j] << "\n"; f << "\t\n"; } f << "\n"; f.close(); } void debug_html() { int n = teachers->size(); if (!n) return; vector g[n]; vector sleft; for (int i=0; isize(); i++) { sleft.push_back( *((string*)students->data(i+1)) ); cout << "PB: " << sleft[i] << endl; } random_shuffle(sleft.begin(), sleft.end()); for (int i=0; itext(i+1) << endl << "---------------------" << endl; for (int j=0; jvalue()); teachers->add(s->c_str(),(void *)s); } void mod_teacher() { int n = teachers->value(); if (n) { string *s = new string(teacher_data->value()); teachers->data(n,(void *)s); teachers->text(n,s->c_str()); } } void del_teacher() { int n = teachers->value(); if (n) teachers->remove(n); } void sel_teacher() { int n = teachers->value(); if (n) teacher_data->value(((string*)teachers->data(n))->c_str()); } void save_teacher_file() { fstream tf; tf.open(teacher_file->value(),fstream::out); if (tf.fail()) return; for (int i=0; isize(); i++) { if (i) tf << endl; tf << *(string*)teachers->data(i+1); } tf.close(); } void load_teacher_file() { fstream tf; tf.open(teacher_file->value(),fstream::in); if (tf.fail()) return; teachers->clear(); while (!tf.eof()) { string *s = new string(); getline(tf, *s); teachers->add(s->c_str(),(void *)s); } tf.close(); } void add_student() { string *s = new string(student_data->value()); students->add(s->c_str(),(void *)s); } void mod_student() { int n = students->value(); if (n) { string *s = new string(student_data->value()); students->data(n,(void *)s); students->text(n,s->c_str()); } } void del_student() { int n = students->value(); if (n) students->remove(n); } void sel_student() { int n = students->value(); if (n) student_data->value(((string*)students->data(n))->c_str()); } void save_student_file() { fstream tf; tf.open(student_file->value(),fstream::out); if (tf.fail()) return; for (int i=0; isize(); i++) { if (i) tf << endl; tf << *(string*)students->data(i+1); } tf.close(); } void load_student_file() { fstream tf; tf.open(student_file->value(),fstream::in); if (tf.fail()) return; students->clear(); while (!tf.eof()) { string *s = new string(); getline(tf, *s); students->add(s->c_str(),(void *)s); } tf.close(); } int main(int argc, char **argv) { Fl_Window *win = make_window(); win->end(); win->show(argc,argv); return Fl::run(); }