我的程序中有一个未指定的错误。该程序针对用户播放石头剪刀。我没有改变源代码中的任何内容。但是当我运行该程序时,它出现了一个未指定的错误。
码
#include <stdio.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include "math.h"
#include <time.h>
#include <cstdlib>
void begin_game();
using namespace std;
int main(){
SetConsoleTitle("Rock Paper Scissors");
string enter_to_continue;
cout<<"Welcome to rock paper scissors \n";
cout<<"Type begin to start \n";
cin>>enter_to_continue;
if (enter_to_continue == "begin"){
begin_game();
}
return 0;
}
//begin game function
void begin_game(){
cout<<"\n";
string player_input;
bool restarting_game = true;
//restarting game while loop
while(restarting_game = (true)){
restarting_game = false;
int seed_random = seed_random + 3;
srand(seed_random);
int ai_random = rand() % 3+1;
cout<<seed_random<<endl;
cout<<"r = rock \n";
cout<<"p = paper \n";
cout<<"s = scissors \n \n";
cout<<"Type r, p, or s \n";
cout<<"You can type exit to exit game \n \n";
cin>>player_input;
if(player_input == "exit"){
restarting_game = false;
cout<<"\n";
exit(0);
}
else{
//rock vs ai
if(player_input == "r" && ai_random == 1){
cout<<"The computer chose rock \n";
cout<<"ITS A TIE RESTARTING \n \n \n";
cout<<"\n \n \n";
bool restarting_game = true;
}
else if(player_input == "r" && ai_random == 2){
cout<<"The computer chose paper \n";
cout<<"YOU LOST RESTARTING \n \n \n \n \n \n \n \n \n \n \n \n \n";
cout<<"\n \n \n";
restarting_game = true;
}
else if(player_input == "r" && ai_random == 3){
cout<<"The computer chose rock \n";
cout<<"YOU WON RESTARTING \n \n \n \n \n \n \n \n \n \n \n \n \n ";
cout<<"\n \n \n";
restarting_game = true;
}
//paper vs ai
if (player_input == "p" && ai_random == 1){
cout<<"The computer chose rock \n";
cout<<"YOU WON RESTARTING \n \n \n \n \n \n \n \n \n \n \n \n \n ";
cout<<"\n \n \n";
restarting_game = true;
}
else if (player_input == "P" && ai_random == 2){
cout<<"The computer chose paper \n";
cout<<"ITS A TIE RESTARTING \n \n \n \n \n \n \n \n \n \n \n \n \n ";
cout<<"\n \n \n";
restarting_game = true;
}
else if (player_input == "p" && ai_random == 3){
cout<<"The computer chose rock \n";
cout<<"YOU LOST RESTARTING \n \n \n \n \n \n \n \n \n \n \n \n \n ";
cout<<"\n \n \n";
restarting_game = true;
}
//scissor vs ai
if (player_input == "s" && ai_random == 1){
cout<<"The computer chose rock \n";
cout<<"YOU LOST RESTARTING \n \n \n \n \n \n \n \n \n \n \n \n \n ";
cout<<"\n \n \n";
restarting_game = true;
}
else if(player_input == "s" && ai_random == 2){
cout<<"The computer chose paper \n";
cout<<"YOU WON RESTARTING \n \n \n \n \n \n \n \n \n \n \n \n \n ";
cout<<"\n \n \n";
restarting_game = true;
}
else if(player_input == "s" && ai_random == 3){
cout<<"The computer chose rock \n";
cout<<"ITS A TIE RESTARTING \n \n \n \n \n \n \n \n \n \n \n \n \n ";
cout<<"\n \n \n";
restarting_game = true;
}
}
}
}
控制台:
C:\Windows\system32\cmd.exe /C ""C:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-make.exe" -j4 SHELL=cmd.exe -e -f Makefile"
"----------Building project:[ aiprogramproject - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/lisa/Desktop/codelight c++/aiprogram/aiprogramproject'
"C:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe" -o ./Debug/aiprogramproject @"aiprogramproject.txt" -L.
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot open output file ./Debug/aiprogramproject.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [Debug/aiprogramproject] Error 1
aiprogramproject.mk:78: recipe for target 'Debug/aiprogramproject' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/lisa/Desktop/codelight c++/aiprogram/aiprogramproject'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====1 errors, 0 warnings====
答案 0 :(得分:1)
确保您的程序未运行。弄干净,然后再试一次。