jose.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //=====================================
- // jose.cpp
- //=====================================
- #include"boyring.h"
- #include"jose.h"
- #include<iostream>
- using namespace std;
- //-------------------------------------
- Jose::Jose(int boys, int interval, int begin):n(boys),m(interval),s(begin){
- if(n<2 || m<1 || m>=n || s<1 || s>=n){
- cerr<<"data error.n";
- throw exception();
- }
- }//------------------------------------
- void Jose::getWinner()const{
- cout<<"There are "<<n<<" boys.nBoys leaved in order:n";
- BoyRing x(n);
- x.countBy(s-1);
- for(int i=1,numinLine=0; i<n; ++i){
- x.countBy(m);
- cout<<" "<<x.getNum()<<(++numinLine%10 ? "" : "n");
- x.disengage();
- }
- cout<<"nthe winner isn "<<x.getNum()<<"n";
- }//------------------------------------