上代码!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <iostream>
#include <stdlib.h>
int a[5005];
using namespace std;
int r(int n, int m) { //产生n~m间的随机数(包括m和n)
double base = ((double)rand()) / RAND_MAX;
int res = n + (base * (double)(m - n + 1));
return res;
}
int main() {
cout << "Please tell me how many players.";
int p;
cin >> p;
int t = 0;
int s = 0;
for (int i = 1; i <= p; i++) {
a[i] = i;
}
int i = 1;
while (p > 1) {
for (int j = 1; j <= p; j++) {
if (a[j] == 0)
continue;
cout << "Player " << a[j] << ": ";
cin >> s;
if (s % r(2, 9) == 0) {
p--;
cout << "Player " << a[j] << " was out.\n";
a[j] = 0;
i++;
system("cls");//清屏(月·吋鞠)
j = 1;
}
}
system("cls");
i++;
}
return 0;
}