??C++???????????
???????????? ???????[ 2014/3/26 11:25:58 ] ????????C++ ???? ???
?????????????????Щ??????????????main??????s1????????????
?????????????????????????????????????????????Χ?????????????????????????????????????????cin??cout??
?????????????????????????????????????
??????д???????????????ó????????????????????????????磬??????????9??5???
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
class shaizi
{
public:
void setdian();
int getdian();
private:
int dian;
};
const int round=9; //round?????????????
int main()
{
shaizi s1??s2;
int i=1??n1=0??n2=0;
while(i<=round)
{
s1.setdian();
s2.setdian();
cout<<"??"<<i<<"??: ?? "<<s1.getdian()<<"????: "<<s2.getdian();
if(s1.getdian()>s2.getdian())
n1++;
else if (s2.getdian()>s1.getdian())
n2++;
else
{
cout<<"????????? ";
continue;
}
i++;
cout<<endl;
if(n1==(round/2+1)||n2==(round/2+1))
break;
}
cout << "??? "<<n1<<" ?????? "<<n2<<" ??";
if(n1>n2)
cout<<"?????"<<endl;
else if(n2>n1)
cout<<"?????"<<endl;
return 0;
}
int shaizi::getdian()
{
return dian;
}
void shaizi::setdian()
{
srand(time(0));
dian=rand()%6+1;
}
?????????????????“????”??set??get??????????У?????????á???main?????ж?????Щ?????????9??5???????????
??????????????????????????
???????????????????????У??2??????????????ζ???????continue?????28-32?е?????????????????У?????????????
?????????????????????????????????rand()????????????????????????????“α???”????????????????“??????”??????????srand(long)???á????????????????????????????????????????????????????????time(0)????????1970??1??1???????????????????????????????????????????????????????????????
???????????????????У?????s1??s2?????????setdian????????????????????????????????????????????????ε??ü?????1??????????1????????????????????????????С???ζ????????????
?????ò????????????????????????????????????????????????“???”?????£????????н???“???”????????????????ó??????????????
???????????£?
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <windows.h>
using namespace std;
class shaizi
{
public:
void setdian();
int getdian();
private:
int dian;
};
const int round=9; //round?????????????
int main()
{
shaizi s1??s2;
int i=1??n1=0??n2=0;
while(i<=round)
{
s1.setdian();
Sleep(1000); //???1000??????1??
s2.setdian();
cout<<"??"<<i<<"??: ?? "<<s1.getdian()<<"????: "<<s2.getdian();
if(s1.getdian()>s2.getdian())
n1++;
else if (s2.getdian()>s1.getdian())
n2++;
else
{
cout<<"????????? "<<endl;
continue;
}
i++;
cout<<endl;
if(n1==(round/2+1)||n2==(round/2+1))
break;
}
cout << "??? "<<n1<<" ?????? "<<n2<<" ??";
if(n1>n2)
cout<<"?????"<<endl;
else if(n2>n1)
cout<<"?????"<<endl;
return 0;
}
int shaizi::getdian()
{
return dian;
}
void shaizi::setdian()
{
srand(time(0)); //??????????????????????????????????????
dian=rand()%6+1; //?????????????????????????????????е?????
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11