void PCR::fill_beta(bool first_time)const{ double a = first_time ? A_prm(false)->value() : this->a(); double b = first_time ? B_prm(false)->value() : this->b(); const Vector &d(first_time ? D_prm(false)->value() : this->d()); uint M = maxscore(); b_[0] = a*(d[0]-b); for(uint m=1; m<=M; ++m) b_[m] = b_[m-1] + a*(d[m]-b); b_.back()=a; beta_->set(b_); beta_current=true; set_abd_current(); }
void rankscore(Student *stu) //考试成绩统计 { int type; do { printf("\n请输入序号选择相应功能\n"); printf("******** 1.求课程最高分 ********\n"); printf("******** 2.求课程最低分 ********\n"); printf("******** 3.求课程平均分 ********\n"); printf("******** 0.退出 ********\n"); scanf("%d",&type); switch(type) { case 0:printf("");break; case 1:maxscore(stu);break; case 2:minscore(stu);break; case 3:avescore(stu);break; default:printf("没有该选项,请重输");break; } }while(type!=0); }
void PCR::fill_abd()const{ uint M = maxscore(); const Vector &beta(this->beta()); assert(beta.size()==M+2); double A = beta.back(); double MA = (M+1)*A; double B = beta[M-1]/(-MA); Vector D(M+1); D[0] = beta[0]+B; double last = 0; for(uint m = 0; m<D.size(); ++m){ D[m] = (beta[m]-last)/A + B; last = beta[m]; } a_prm->set(A); // mutable pointers get around const-ness b_prm->set(B); d_prm->set(D); // the 'set' operations modify beta_current beta_current=true; // set it right again set_abd_current(); }
int main() { char row,col,row1,col1,wwin,bwin; step_t white,black; int count = 0; int i,j; char board[15][15]= {0}; char score1[15][15]= {0}; char score2[15][15]= {0}; FILE*fin = NULL; FILE*fout = NULL; // srandom(time(NULL)); while(count <= 112) { // printf("¿%d¿¿¿¿¿¿%c%d\n",count,col+97,row+1); // print_board( board ); // printf("¿%d¿¿¿¿¿¿%c%d\n",count,col1+97,row1+1); black = read_step("black.pipe",BLACK); row = black.row; col = black.col; board[row][col] = BLACK; printf("The%dround blackchess go to the:%c%d\n",count,col+97,row+1); print_board( board ); printf("The%dround whitechess go to the:%c%d\n",count,col1+97,row1+1); // printf("¿%d¿¿¿¿¿%d¿%c¿\n",count,col,row+'A'); // bwin = black_gamelow(board); bwin = gamelow(board,black); if(1 == bwin) { print_board( board ); printf("blackchess is the winner!\n"); return 0; } for(i = 0;i < 0xfff;i++) { for(j = 0;j < 0xffff;j++); } // print_board( board ); // you = you_move(board,WHITE); //¼º·½Îª°×·½£» maxscore(board,score1,BLACK); maxscore(board,score2,WHITE); white = chessjudge(score1,score2,WHITE); row = white.row; col = white.col; board[row][col] = white.player; print_board( board ); // maxscore(board,score2,WHITE); // row = white.row; // col = white.col; // board[row][col] = WHITE; write_step("white.pipe",white); // printf("¿%d¿¿¿¿¿%d¿%c¿\n",count,col,row+'A'); // wwin = white_gamelow(board); wwin = gamelow(board,white); if(1 == bwin) { print_board( board ); printf("whitechess is the winner!\n"); return 0; } count++; } return 0; }
void PCR::set_d(const Vector &D){ assert(D.size()==maxscore()+1); // ==nlevels D_prm()->set(D); d_current=true; }
void PCR::setup_beta(){ uint M = maxscore(); if(d0_is_fixed) beta_ = new ConstrainedVectorParams(M+2); fill_beta(true); b_ = beta_->value(); }