📄 assignment6-2-2_result_roll_dice.cpp
字号:
#include <iostream>
using namespace std;
int main ()
{ int d1[1000], d2[1000], d3[1000];
int c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0;
int ctotal;
srand(time(NULL)*time(NULL));
for (int i=1;i<=1000;i++)
{
d1[i] = (1+(rand()%6));
d2[i] = (1+(rand()%6));
d3[i] = d1[i]+d2[i];
cout << "Dice Roll are : " << d1[i] << " + " << d2[i] << " Equal : " << d3[i] << " Point(s)" << "\n";
if (d3[i] == 2)
c2++;
else if (d3[i]== 3)
c3++;
else if (d3[i]== 4)
c4++;
else if (d3[i]== 5)
c5++;
else if (d3[i]== 6)
c6++;
else if (d3[i]== 7)
c7++;
else if (d3[i]== 8)
c8++;
else if (d3[i]== 9)
c9++;
else if (d3[i]== 10)
c10++;
else if (d3[i]== 11)
c11++;
else if (d3[i]== 12)
c12++;
}
cout << endl;
cout << " +++Count time of Roll Dice+++" << endl;
cout << "========================================" << "\n";
cout << "roll give 2 point : " << c2 << " time(s)" << "\n";
cout << "roll give 3 point : " << c3 << " time(s)" << "\n";
cout << "roll give 4 point : " << c4 << " time(s)" << "\n";
cout << "roll give 5 point : " << c5 << " time(s)" << "\n";
cout << "roll give 6 point : " << c6 << " time(s)" << "\n";
cout << "roll give 7 point : " << c7 << " time(s)" << "\n";
cout << "roll give 8 point : " << c8 << " time(s)" << "\n";
cout << "roll give 9 point : " << c9 << " time(s)" << "\n";
cout << "roll give 10 point : " << c10 << " time(s)" << "\n";
cout << "roll give 11 point : " << c11 << " time(s)" << "\n";
cout << "roll give 12 point : " << c12 << " time(s)" << "\n";
cout << "========================================" << "\n";
ctotal = c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12;
cout << "Total : " << ctotal << " Time(s)" << "\n";
system ("pause");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -