jose.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:

C#编程

开发平台:

Visual C++

  1. //=====================================
  2. // jose.cpp
  3. //=====================================
  4. #include"boyring.h"
  5. #include"jose.h"
  6. #include<iostream>
  7. using namespace std;
  8. //-------------------------------------
  9. Jose::Jose(int boys, int interval, int begin):n(boys),m(interval),s(begin){
  10.   if(n<2 || m<1 || m>=n || s<1 || s>=n){
  11.     cerr<<"data error.n";
  12.     throw exception();
  13.   }
  14. }//------------------------------------
  15. void Jose::getWinner()const{
  16.   cout<<"There are "<<n<<" boys.nBoys leaved in order:n";
  17.   BoyRing x(n);
  18.   x.countBy(s-1);
  19.   for(int i=1,numinLine=0; i<n; ++i){
  20.     x.countBy(m);
  21.     cout<<"  "<<x.getNum()<<(++numinLine%10 ? "" : "n");
  22.     x.disengage();
  23.   }
  24.   cout<<"nthe winner isn  "<<x.getNum()<<"n"; 
  25. }//------------------------------------
  26.