希望能提供思路或是流程图目前我知道我需要用srand来随机发牌和用loop来循环5次但实际应用并不知道从何下手了
这是我目前的思路,,我觉得挺混乱的。。
(1) Get and input the Beyblade cards attributes, including {serial number (#) and Beyblade Name, product code, type, plus mode, system}
(2) Get the player one and two name.
(3) string the product code, type, plus mode, system into the Beyblade assigned number (#).
Sting Beyblade assigned number (#)
Assigned number (#) = Beyblade Name, product code, type, plus mode, system
(4) Set the type precedence and system precedence
Type precedence: Stamina with Plus Mode > Balance > Attack > Defense
System precedence: QuadDrive > HyperSphere > SpeedStorm > Burst > SwitchStrike > Dual-Layer > SlingShock
(5) Randomly the card assigned numbers 1-10 and limited the range
Player one Unsigned numbers 1-10 input x[10], I, j for the variable and limition
Srand numbers 1-10
X=1+(rand()%10-1+1)+1
Limiting the range
Let the range interval be (max, min).
Then only rand%(max-min+1)+min is required
Just in case for repeat the assigned number from Player two, use if and break to reproduce new number until not repeat. If X{i} ==X{j} then i--,break
Unsigned the remaining cards 1-9
#include <iostream>
using namespace std;
#include <stdlib.h>
#include <time.h>
int main()
{
int i;
srand((unsigned)time(NULL)); //初始化随机数种子
for (i=0; i<10; i++) //产生10个随机数
{
if (i=8) loop;
cout<<rand()<<"\t";
}
cout<<endl;
getchar();
return 0;
}