#include <iostream>
#include <ctime>
#include <vector>
using namespace std;
int main()
{
//first method
for(int i =1; i<=50; ++i)
cout << i << ", "<< 50+i <<", ";
//second method
srand(time(NULL));
vector<int> v;
while (v.size()<100)
{
if (v.size()%2==0)
{
int g=rand()%50+1;
int count=0;
for (int i =0; i<v.size(); ++i)
if (v[i]==g)
count++;
if (count==0)
v.push_back(g);
}
else
{
int g=rand()%50+51;
int count=0;
for (int i =0; i<v.size(); ++i)
if (v[i]==g)
count++;
if (count==0)
v.push_back(g);
}
}
for (int j=0; j<v.size(); ++j)
cout << v[j] <<",";
return 0;
}
Comments
Leave a comment