sorting random numbers

So i want to sort generated random numbers with a function but it doesnt work properly it just shows the same range as the generated numbers and how to check how many repeated numbers are within the range, here is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 #include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
void sortovektorin(int X[],int n);
void shtypvektorin(int X[],int n);
int getRandNumb();
int main()
{
   const int m=7;
   int A[m],i;
   srand(time(NULL));
   cout<<"****Loja LOTO nga 7 ne 39****"<<endl;
   cout<<"================================="<<endl;

   for (int i= 0; i<m ; i++)
   {
      A[i] = getRandNumb();
      cout << A[i]
           << " ";
   }
   cout<<"\n";
   cout<<"---------------------------------"<<endl;
   sortovektorin(A,m);
   shtypvektorin(A,m);
   cout<<"---------------------------------"<<endl;

   return 0;
}

int getRandNumb()
{
    return 1 + rand()% 39;
}
int kontrolla(int X[],int n)
{

}
void sortovektorin(int X[],int n)
{
    int i,b,j;
    for(i=0;i<n-1;i++)
        for(j=i+1;i<n;i++)
        {
            if(X[i]>=X[j])
            {
            b=X[i];
            X[i]=X[j];
            X[j]=b;
            }
        }
}
void shtypvektorin(int X[],int n)
{
    int i;
    for(i=0;i<n;i++)
    {
    cout<<X[i]
        <<" ";
    }
    cout<<"\n";
}
Line 43 test and modifies i?
how did i do that ?haha thanks man, any clue how to find when a number is repeated in the range ?
Fiton wrote:
any clue how to find when a number is repeated in the range ?

try unordered set
http://en.cppreference.com/w/cpp/container/unordered_set
Last edited on
Topic archived. No new replies allowed.