首先,我是一个早期的初学者程序员,希望得到一些帮助。
我编写了以下代码,从我测试过的代码中生成:
- 5 个随机数:1 到 39 //num1gen 到 num5gen - eggroup A
- 1 个介于:1 和 14 之间的随机数 //Thunderball - eggroup B
我只想按升序计算<< A组数字,我不确定添加此功能需要什么编码。
我仍然需要将生成的随机数放在下面显示的整数名称中:
IE
- num1gen = 12
- num2gen = 24
- num3gen = 3
- num4gen = 5
- num5gen = 32
- 雷球 = 12
错误:ISO C++ 在第 16 行禁止没有类型 [-fpremissive] 的“i”减速。
到目前为止,我在以下用户的帮助下完成了代码:
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
srand(time(NULL));
std::vector<int> numA(5);
srand( time(NULL) );
for( auto i(0); i < numA.size(); ++i ) //line no 16 error
numA[i] = (rand()%49+1);
int num1gen=(rand()%49+1); // this is the value of ball no.1
int num2gen=(rand()%49+1); // this is the value of ball no.2
int num3gen=(rand()%49+1); // this is the value of ball no.3
int num4gen=(rand()%49+1); // this is the value of ball no.4
int num5gen=(rand()%49+1); // this is the value of ball no.5
std::sort(numA.begin(), numA.end());
num1gen=numA[0];
num2gen=numA[1];
num3gen=numA[2];
num4gen=numA[3];
num5gen=numA[4];
cout<<num1gen<< ", "<<num2gen<< ", "<<num3gen<< ", "<<num4gen<< ", "
<<num5gen<< " ";"
return 0;
}