1
我正在編寫一個程序,該程序必須在0-9之間創建一個5個隨機數字的數組,然後我必須要求用戶輸入0-9之間的5個數字並將其存儲在數組中,然後比較它們並顯示它們是否已經全部正確。我寫了這一切,但它不斷給我這個錯誤C++樂透號碼發生器
Error 1 error C1075: end of file found before the left brace '{' at
'c:\users\bigt\documents\visual studio 2012\projects\consoleapplication2\
consoleapplication2\source.cpp(9)'
was matched c:\users\bigt\documents\visual studio 2012\projects\
consoleapplication2\consoleapplication2\source.cpp 65 1
ConsoleApplication2
這讓我覺得我有一個邏輯上的錯誤,誰能幫助我找到在哪裏我做錯了什麼?
//#include "stdafx.h"
#include <iostream>
#include <cstdlib>
using namespace std;
//void showValues(int[], int);
int main()
{
const int array_size = 5;
int numbers[array_size];
int win_num[array_size];
int count = 0;
cout << "enter your altto drawing" <<endl;
for(int i = 0; i < array_size; i++)
{
cin >> numbers[i];
}
for (int i = 0 ; i < array_size; i++)
{
win_num[i] = rand()%10;
}
for (int i =0; i < array_size; i++)
{
if (numbers[i] != win_num[i])
{
cout << "sorry try again" << endl;
}
else
{
count++;
}
if (count == 5)
{
cout << " you win" << endl;
}
else
{
cout << " you did not win, you had" << count << "right numbers" << endl;
}
cout << "the winning numbers are" << endl;
for(int i = 0; i < array_size ; i ++)
{
cout << win_num[i] << " ";
}
system ("pause");
return 0;
}
你應該使用''頭來產生僞隨機數。 –
chris
多數民衆贊成在很奇怪的是我錯過了我的}在統計爲什麼沒有我的IDE顯示我有語法錯誤? – stev0104