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