|
|
вернуться в форумWhat's the version of the judge's C++ compiler? My program can be compiled correctly by both Borland C++ Builder 5.0 and GNU C++ 2.95. But it got CE on the judge. I wonder why? And this is my program. And this is my program: ============================================== #include <iomanip.h> #include <iostream.h> #include <string.h> const int max_survey_name_len=100; const int max_question_name_len=80; const int question_code_len=3; const int max_answer_name_len=40; const int max_questions_per_survey=100; const int max_answers_per_question=10; const int max_number_of_results=10000; const int max_cross_table_name_len=100; const int buf_size=256; inline int char_to_number(char c) { if(c>='0'&&c<='9') return c-'0'; else if(c>='A'&&c<='Z') return c-'A'+10; else switch(c) { case '.': return 36; case '*': return 37; case '@': return 38; default: return -1; } } inline void new_line(void) { char buf[buf_size]; cin.getline(buf,buf_size); } struct TCell { int number; int percentage_of_row; int percentage_of_column; int flag_of_row; int flag_of_column; }; class TAnswer { public: void init(void); void output(void); char get_code(void) { return code; } private: char code; char name[max_answer_name_len+1]; }; class TQuestion { public: void init(void); void output(void); int get_answer_id(char c) { return map[char_to_number(c)]; } char *get_code(void) { return code; } int get_n_answers(void) { return n_answers; } char get_answer(int no) { return answer[no].get_code(); } private: char code[question_code_len+1]; char name[max_question_name_len+1]; int n_answers; TAnswer answer[max_answers_per_question]; int map[39]; int next_answer(void); }; class TSurvey { public: void init(void); void get_result(void); int get_cross_table(void); void generate(void); void output(void); private: char name[max_survey_name_len+1]; int n_questions; TQuestion question[max_questions_per_survey]; int n_persons; int result_id[max_number_of_results]; int q1,q2; char cross_table_name[max_cross_table_name_len+1]; TCell table[max_answers_per_question+1] [max_answers_per_question+1]; int next_question_or_person(void); int get_question_id(void); }; void TAnswer::init(void) { cin.get(code); cin.ignore(1); cin.getline(name,max_answer_name_len+1); } void TAnswer::output(void) { cout<<" "<<code<<" "<<name<<endl; } int TQuestion::next_answer(void) { char c; cin.get(c); if(c==' ') return 1; else { cin.unget(); return 0; } } void TQuestion::init(void) { cin.get(code,question_code_len+1); cin.ignore(1); cin.getline(name,max_question_name_len+1); n_answers=0; memset(map,-1,sizeof(map)); while(next_answer()) { answer[n_answers].init(); map[char_to_number(answer[n_answers].get_code())]=n_answers; n_answers++; } } void TQuestion::output(void) { cout<<code<<" "<<name<<endl; for(int i=0;i<n_answers;i++) answer[i].output(); } int TSurvey::next_question_or_person(void) { char c; cin.get(c); if(c!='#') { cin.unget(); return 1; } else { new_line(); return 0; } } void TSurvey::init(void) { cin.getline(name,max_survey_name_len+1); n_questions=0; while(next_question_or_person()) question[n_questions++].init(); } void TSurvey::get_result(void) { n_persons=0; while(next_question_or_person()) { char buf[buf_size]; cin.getline(buf,buf_size); for(int i=0;i<n_questions;i++) result_id[n_persons*n_q You can't do this here (+) for (int j=0; j<xxx; j++) sjdkfjlksdf(j); for (int j=0; j<xxx; j++) sdfsdf(j); but you can do this for (int j=0; j<xxx; j++) sdfsdfsdf(j); for (j=0; j<sdfsdf; j++) sfsdf(j); Thanks. I have already modified my program, but it still got a CE. btw, what's the C++ compiler of the judge? use as standard (i.e. ANSI) code as possible (+) I compiled your program with Turbo C++ 3.0 and found "unget is not a member of istream_withassign" I don't know what is C++ compiler here either. But I always keep in mind that ANSI didn't define every molecule of C/C++. |
|
|