Я кодирую игру farkle, и я сталкиваюсь с этой проблемой, хотя все, кроме двух, моих утверждений if - это bools.Запрещает сравнение указателя с целым числом?
Кроме того, как я могу позволить пользователю бросить конкретные кости? BloodshedDev/другие IDE, похоже, пока не работают в Windows 8, поэтому я использую Ideone и не имею ничего общего с этим.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
//global vars
int bubblehold;
int roll[6];
int score;
int bank;
int dicecatch;
int tempscore = 0;
int dicenum = 6;
//function prototype
void bubblesort(int[], int);
bool straightsix();
bool sixkind();
bool fivekind();
bool fourkind();
bool threekind();
int onefive();
int main() {
srand(time(0));
for(int i=0; i=dicenum-1; i++){
roll[i] = rand()%6+1;
}
bubblesort(roll,dicenum);
for(int i=0; i=dicenum-1; i++){
cout<< roll[i] <<", ";
}
if(straightsix == true){
tempscore = 1500;
}
else if(sixkind == true){
tempscore = 3000;
}
else if(fivekind == true){
tempscore = 2000;
}
else if(fourkind == true){
tempscore = 1000;
}
else if(threekind == true){
cout<< tempscore;
}
else if(onefive == 1){
tempscore = dicecatch * tempscore;
cout<< tempscore;
}
else if(onefive == 5){
tempscore = dicecatch * tempscore;
cout<< tempscore;
}
return 0;
}
void bubblesort(int a[], int x){
for (int i = 0; i < x-1; i++){
bubblehold = a[i+1];
a[i+1] = a[i];
a[i] = bubblehold;
}
}
bool straightsix(){
for(int i=0; i<5; i++){
if(roll[i]+1 != roll[i+5]){
return false;
}
}
}
bool sixkind(){
for(int i=0; i=5; i++){
if (roll[i] != roll[i+5]){
return false;
}
}
}
bool fivekind(){
for(int i=0; i=4; i++){
if (roll[i] != roll[i+4]){
return false;
}
}
}
bool fourkind(){
for(int i=0; i=3; i++){
if (roll[i] != roll[i+3]){
return false;
}
}
}
bool threekind(){
for(int i=0; i=2; i++){
if (roll[i] != roll[i+2]){
return false;
}
else if(i=1){
dicecatch = 3;
tempscore = dicecatch * 100;
return true;
}
else{
dicecatch = i;
tempscore = dicecatch * 100;
return true;
};
}
}
int onefive(){
for(int i=0; i=dicenum; i++){
if(roll[i] == 1){
dicecatch = dicecatch + 1;
tempscore = tempscore + 100;
return 1;
}
else if(roll[i] == 5){
dicecatch = dicecatch + 1;
tempscore = tempscore + 50;
return 5;
}
}
}
Я думаю, что вы имели в виду 'if (straightsix() == true)' и т. Д. И т. Д. И т. Д. И т. Д. – user657267
* «Я столкнулся с этой проблемой» * Какая проблема? Где? –
Вы не должны писать этот код, не тестируя его. – Beta