- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int a, b;
- srand(time(NULL));
- cout<<"***擲骰子遊戲***"<<endl;
- a=rand()%6+1;
- cout<<"電腦擲出的點數為"<<a<<"點!"<<endl;
- cout<<"輪到你擲了!"<<endl;
- system("pause");
- b=rand()%6+1;
- cout<<"你擲出的點數為"<<b<<"點!"<<endl;
- if(a>b)
- {
- cout<<"下次再加油, 這次你輸了!"<<endl;
- }else if(b>a)
- {
- cout<<"恭喜你,你贏了!"<<endl;
- }else
- {
- cout<<"平手!"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |