這就是:C++我的程序混淆了我很大的
#include <iostream>
#include <cstdlib> // for rand() and srand()
#include <ctime>
using namespace
int main()
{
//cout << "How many players?" << endl;
int numplayers=1;
//cin >> numplayers;
int players[numplayers];
int x=0,y=0;
srand(time(0));
x=(rand() % 6 + 1);
y=(rand() % 6 + 1);
players[1]=players[1]+x+y;
cout << ("Your score is" + players[1]) << endl;
cin >> numplayers;
}
好了我原來的問題是,這總是崩潰,現在它打印「@」 ???
這是沒有很好地形成的C++。 –
你明確地創建一個長度爲1的數組,然後嘗試訪問第二個元素... – David
是的,我剛剛開始與C++ .. :) – Colonbracket