File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 2727 M 3 vs 3 => blue win
2828 O 2 vs 1 => red win
2929*/
30+ #include < iostream>
31+ #include < cstdlib>
32+ #include < ctime>
33+ #include < algorithm>
34+ using namespace std ;
35+
36+ void throwDices (int *v, size_t n){
37+ for (int i=0 ; i<n; i++){
38+ v[i] = (rand () % 6 ) + 1 ;
39+ }
40+ sort (v, v+n, greater<int >());
41+ }
42+
43+ int main () {
44+ srand (time (nullptr ));
45+ int v1[3 ],v2[3 ];
46+ char chs[3 ]= {' N' , ' M' , ' O' };
47+ throwDices (v1, 3 );
48+ throwDices (v2, 3 );
49+ cout << " Red dices: " << endl;
50+ for (int i=0 ; i<3 ; i++){
51+ cout << v1[i] << " (" << chs[i] << " )" << endl;
52+ }
53+ cout << " \n Blue dices: " << endl;
54+ for (int i=0 ; i<3 ; i++){
55+ cout << v2[i] << " (" << chs[i] << " )" << endl;
56+ }
57+
58+ printf (" \n %3.c%5.c\n " , ' R' , ' B' );
59+ for (int i=0 ; i<3 ; i++){
60+ cout << chs[i] << " " << v1[i] << " vs " << v2[i] << " => " << (v1[i]>v2[i] ? " red win" : " blue win" ) << endl;
61+ }
62+ }
You can’t perform that action at this time.
0 commit comments