⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assignment 6-2-2-result rolling 2 dice.cpp

📁 this code is code c++. have many lesson
💻 CPP
字号:
#include<iostream>
#include<ctime>

using namespace std;
int main()
{
 int d1[1000],d2[1000],d3[1000];
 int c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,ctotal;
 /*srand(TIME(NULL)*TIME(NULL));*/
 for(int i = 0 ; i < 1000 ; i++)
{
 d1[i] = 1+(rand()%6);
 d2[i] = 1+(rand()%6);
 d3[i] = d1[i] + d2[i];
 
 cout << "Time [" << i << "] : " << d3[i] << endl;
 
 if(d3[i] == 2)
 c2++;
 if(d3[i] == 3)
 c3++;
  if(d3[i] == 4)
 c4++;
  if(d3[i] == 5)
 c5++;
  if(d3[i] == 6)
 c6++;
  if(d3[i] == 7)
 c7++;
  if(d3[i] == 8)
 c8++;
  if(d3[i] == 9)
 c9++;
  if(d3[i] == 10)
 c10++;
  if(d3[i] == 11)
 c11++;
  if(d3[i] == 12)
 c12++;
}
cout << endl;
cout << "++++++++++++++++++Check Time(s)+++++++++++++++++" << endl;
cout << "------------------------------------------------" << endl;
cout << "2 Point : " << c2 << " time(s)" << endl;
cout << "3 Point : " << c3 << " time(s)" << endl;
cout << "4 Point : " << c4 << " time(s)" << endl;
cout << "5 Point : " << c5 << " time(s)" << endl;
cout << "6 Point : " << c6 << " time(s)" << endl;
cout << "7 Point : " << c7 << " time(s)" << endl;
cout << "8 Point : " << c8 << " time(s)" << endl;
cout << "9 Point : " << c9 << " time(s)" << endl;
cout << "10 Point : " << c10 << " time(s)" << endl;
cout << "11 Point : " << c11 << " time(s)" << endl;
cout << "12 Point : " << c12 << " time(s)" << endl;
cout << "-------------------------------------------------" << endl;
ctotal=c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12;
cout << "Total Time(s) : " << ctotal << " Time(s)"<< endl << endl;

 system("PAUSE");
 return 0;    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -