C++ 自动比较的编译错误

C++ 自动比较的编译错误,c++,C++,我的代码在代码块中编译得非常完美,但在eclips中编译时显示了很多错误。有人能提出解决办法吗 #include<iostream> #include<cstdlib> #include <algorithm> #include<ctime> #include<iomanip> #include<vector> using namespace std; int myrandom (int i) { retur

我的代码在代码块中编译得非常完美,但在eclips中编译时显示了很多错误。有人能提出解决办法吗

 #include<iostream>
 #include<cstdlib>
 #include <algorithm>
 #include<ctime>
 #include<iomanip>
 #include<vector>
 using namespace std;
 int myrandom (int i) { return std::rand()%i;}
 int card_to_move(vector<string> input) // function to check if the players    has the same suit
{
int i =0; int j;
char suit = input.at(0).at(0);
for (auto comparison : input)
    {
        if (comparison.at(0) == suit){
                                        i++;
                                        }
        else{j=i;break;}
    }return j;
}
bool are_all_same_suit(vector<string> input)// function to compare suits
{
char suit = input.at(0).at(0);
for (auto comparison : input)
    {
        if (comparison.at(0) != suit) return false;
    }
return true;
}
int main()
{

srand ( unsigned ( std::time(0) ) );
vector<string> myvector;
vector<string>all_cards;
vector<string>player_0;
vector<string>player_1;
vector<string>player_2;
vector<string>player_3;
vector<string>player_4;
vector<string>cards=    {"DA","DK","DQ","DJ","D2","D3","D4","D5","D6","D7","D8","D9","D10",
                        "HA","HK","HQ","HJ","H2","H3","H4","H5","H6","H7","H8","H9","H10",
                        "SA","SK","SQ","SJ","S2","S3","S4","S5","S6","S7","S8","S9","S10",
                        "CA","CK","CQ","CJ","C2","C3","C4","C5","C6","C7","C8","C9","C10"};// vector holding all the cards

 // set some values:
for (int i=1; i<52; ++i) myvector.push_back(cards[i]);

// using built-in random generator:
random_shuffle ( myvector.begin(), myvector.end() );

// using myrandom:
random_shuffle ( myvector.begin(), myvector.end(), myrandom);// shuffling so that a cards is not generated twice
  for (std::vector<string>::iterator it=myvector.begin(); it!=myvector.end(); ++it){
//std::cout << ' ' << *it;

all_cards.push_back(*it);}//all cards saved at all_cards
for(int i=0;i<7;i++){
    player_0.push_back(all_cards[i]);
    player_1.push_back(all_cards[i+9]);
    player_2.push_back(all_cards[i+18]);
    player_3.push_back(all_cards[i+27]);
    player_4.push_back(all_cards[i+36]);
                    }
string x,a,b,c,d,e,f,g,y;
a=player_0[0];b=player_0[1];c=player_0[2];d=player_0[3];e=player_0[4];f=player_0[5];g=player_0[6];
cout<<"player_0 (a)"<<a<<setw(5)<<"(b)"<<b<<setw(5)<<"(c)"<<c<<setw(5)<<"(d)"<<d<<setw(5)<<"(e)"<<e<<setw(5)<<"(f)"<<f<<setw(5)<<"(g)"<<g<<endl;
char choice; // player_0' choice
cout << "which one to replace ?"<<endl;
while(cin >> choice)
{
cout << "which one to replace ?"<<endl;
char check;


switch (choice){  // switch the option the player is choosing
case 'a':
player_1.push_back(player_0[0]);
player_0.erase(player_0.begin());

break;
case 'b':
player_1.push_back(player_0[1]);
player_0.erase(player_0.begin()+1);

break;
case 'c':
player_1.push_back(player_0[2]);
player_0.erase(player_0.begin()+2);

break;
case 'd':
player_1.push_back(player_0[3]);
player_0.erase(player_0.begin()+3);

break;
case 'e':
player_1.push_back(player_0[4]);
player_0.erase(player_0.begin()+4);

break;
case 'f':
player_1.push_back(player_0[5]);
player_0.erase(player_0.begin()+5);

break;
case 'g':
player_1.push_back(g);
player_0.erase(player_0.begin()+6);

break;
case '?':
  cout<<"player_0 (a)"<<a<<setw(5)<<"(b)"<<b<<setw(5)<<"(c)"<<c<<setw(5)<<"(d)"<<d<<setw(5)<<"(e)"<<e<<setw(5)<<"(f)"<<f<<setw(5)<<"(g)"<<g<<endl;
  cout<<"player_1 (a)"<<player_1[0]<<setw(5)<<"(b)"<<player_1[1]<<setw(5)<<"(c)"<<player_1[2]<<setw(5)<<"(d)"<<player_1[3]<<setw(5)<<"(e)"<<player_1[4]<<setw(5)<<"(f)"<<player_1[5]<<setw(5)<<"(g)"<<player_1[6]<<endl;
  cout<<"player_2 (a)"<<player_2[0]<<setw(5)<<"(b)"<<player_2[1]<<setw(5)<<"(c)"<<player_2[2]<<setw(5)<<"(d)"<<player_2[3]<<setw(5)<<"(e)"<<player_2[4]<<setw(5)<<"(f)"<<player_2[5]<<setw(5)<<"(g)"<<player_2[6]<<endl;
  cout<<"player_3 (a)"<<player_3[0]<<setw(5)<<"(b)"<<player_3[1]<<setw(5)<<"(c)"<<player_3[2]<<setw(5)<<"(d)"<<player_3[3]<<setw(5)<<"(e)"<<player_3[4]<<setw(5)<<"(f)"<<player_3[5]<<setw(5)<<"(g)"<<player_3[6]<<endl;
  cout<<"player_4 (a)"<<player_4[0]<<setw(5)<<"(b)"<<player_4[1]<<setw(5)<<"(c)"<<player_4[2]<<setw(5)<<"(d)"<<player_4[3]<<setw(5)<<"(e)"<<player_4[4]<<setw(5)<<"(f)"<<player_4[5]<<setw(5)<<"(g)"<<player_4[6]<<endl;
  cout << endl;
  cout << "which one to replace ?"<<endl;
  break;
default:
break;

}
// checking if the player has the same suit of cards
    if(are_all_same_suit(player_0)==true){
    cout<<"player_0 wins"<<endl;
    break;
    }
    else if(are_all_same_suit(player_1)==true){
    cout<<"player_1 wins" <<endl;
    break;
    }
    else if(are_all_same_suit(player_2)==true){
    cout<<"player_2 wins" <<endl;
    break;
    }
    else if(are_all_same_suit(player_3)==true){
    cout<<"player_3 wins" <<endl;
    break;
    }
    else if(are_all_same_suit(player_4)==true){
    cout<<"player_4 wins" <<endl;
    break;
    }
    else{ // if the player has mismatch cards they choose to obtain different cards
        if(choice=='?'){continue;}
        if(are_all_same_suit(player_1)!=true){
            player_2.push_back(player_1[card_to_move(player_1)]);
            player_1.erase(player_1.begin()+(card_to_move(player_1)));}
        if(are_all_same_suit(player_2)!=true){
            player_3.push_back(player_2[card_to_move(player_2)]);
            player_2.erase(player_2.begin()+(card_to_move(player_2)));

            }
        if(are_all_same_suit(player_3)!=true){
            player_4.push_back(player_3[card_to_move(player_3)]);
            player_3.erase(player_3.begin()+(card_to_move(player_3)));

        }
        if(are_all_same_suit(player_4)!=true){
            player_0.push_back(player_4[card_to_move(player_4)]);
            player_4.erase(player_4.begin()+(card_to_move(player_4)));}
    }a=player_0[0];b=player_0[1];c=player_0[2];d=player_0[3];e=player_0[4];f=player_0[5];g=player_0[6];
    cout<<"(a)"<<a<<setw(5)<<"(b)"<<b<<setw(5)<<"(c)"<<c<<setw(5)<<"(d)"<<d<<setw(5)<<"(e)"<<e<<setw(5)<<"(f)"<<f<<setw(5)<<"(g)"<<g<<endl;
 }
}
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
int myrandom(int i){return std::rand()%i;}
int card_to_move(矢量输入)//用于检查玩家是否有相同的套装
{
int i=0;int j;
char suit=input.at(0).at(0);
用于(自动比较:输入)
{
如果(在(0)处的比较)=诉讼{
i++;
}
else{j=i;break;}
}返回j;
}
bool\u all\u same\u suit(矢量输入)//用于比较套装的函数
{
char suit=input.at(0).at(0);
用于(自动比较:输入)
{
如果(比较。在(0)!=suit)返回false;
}
返回true;
}
int main()
{
srand(无符号(std::time(0));
向量myvector;
矢量卡;
矢量播放器_0;
矢量播放器_1;
矢量播放器2;
矢量播放器3;
矢量播放器4;
矢量卡={“DA”、“DK”、“DQ”、“DJ”、“D2”、“D3”、“D4”、“D5”、“D6”、“D7”、“D8”、“D9”、“D10”,
“HA”、“HK”、“HQ”、“HJ”、“H2”、“H3”、“H4”、“H5”、“H6”、“H7”、“H8”、“H9”、“H10”,
“SA”、“SK”、“SQ”、“SJ”、“S2”、“S3”、“S4”、“S5”、“S6”、“S7”、“S8”、“S9”、“S10”,
“CA”、“CK”、“CQ”、“CJ”、“C2”、“C3”、“C4”、“C5”、“C6”、“C7”、“C8”、“C9”、“C10”};//包含所有卡的向量
//设置一些值:

对于(int i=1;请忽略我的缩进。我知道这不太正确。另外,我是编程新手,所以请尽可能详细地告诉我。我在上面的链接中找不到解决方案,然后您没有仔细阅读。命令
g++-O0-g3-Wall-c-fmessage length=0-o“src\\my ship sails!.o”“\\src\\my ship sails!.cpp”缺少以C++ 11为目标的编译开关。在Eclipse的最新版本中:Projt:> Projt:C+C++ Budio->设置>工具设置-> GCC C++编译器>方言。从下拉中选择一个方言。