|
Senior Member
|
之前受大家幫忙~來回饋一下
小弟也是新手~方法很濫不要罵我
#include<iostream>
using std::cin;
using std::cout;
int main()
{
int p;
int n=0;
double a=0;
double b=0;
double c=0;
double d=0;
double e=0;
double f=0;
double g=0;
double h=0;
double i=0;
double j=0;
cout<<"Please enter 6 number : ";
while (n < 6){
switch (p=cin.get()) {
case '1':
++a;
break;
case '2':
++b;
break;
case '3':
++c;
break;
case '4':
++d;
break;
case '5':
++e;
break;
case '6':
++f;
break;
case '7':
++g;
break;
case '8':
++h;
break;
case '9':
++i;
break;
case '0':
++j;
break;
}
n++;
}
cout<<"The probability of the number 1 :"<<a/6*100<<"%\n"
<<"The probability of the number 2 ::"<<b/6*100<<"%\n"
<<"The probability of the number 3 ::"<<c/6*100<<"%\n"
<<"The probability of the number 4 ::"<<d/6*100<<"%\n"
<<"The probability of the number 5 ::"<<e/6*100<<"%\n"
<<"The probability of the number 6 ::"<<f/6*100<<"%\n"
<<"The probability of the number 7 ::"<<g/6*100<<"%\n"
<<"The probability of the number 8 ::"<<h/6*100<<"%\n"
<<"The probability of the number 9 ::"<<i/6*100<<"%\n"
<<"The probability of the number 0 ::"<<j/6*100<<"%\n";
return 0;
}
|