File tree 1 file changed +15
-15
lines changed
1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 3
3
4
4
using namespace std ;
5
5
6
- void insertionSort (vector<int > &vetor ) {
6
+ void insertionSort (vector<int > &vector ) {
7
7
8
- for (uint32_t indice = 1 ; indice < vetor .size (); indice ++)
8
+ for (uint32_t index = 1 ; index < vector .size (); index ++)
9
9
{
10
- int chave = vetor[indice ];
11
- int i = indice - 1 ;
10
+ int key = vector[ index ];
11
+ int i = index - 1 ;
12
12
13
- while (i >= 0 && vetor [i] > chave )
13
+ while (i >= 0 && vector [i] > key )
14
14
{
15
- vetor [i+1 ] = vetor [i];
15
+ vector [i+1 ] = vector [i];
16
16
i--;
17
17
}
18
18
19
- vetor [i+1 ] = chave ;
19
+ vector [i+1 ] = key ;
20
20
}
21
21
}
22
22
23
- void showVector (vector<int > vetor )
23
+ void showVector (vector<int > vector )
24
24
{
25
- for (uint32_t i = 0 ; i < vetor .size (); ++i)
25
+ for (uint32_t i = 0 ; i < vector .size (); ++i)
26
26
{
27
- cout << vetor [i] << " , " ;
27
+ cout << vector [i] << " , " ;
28
28
}
29
29
cout << " \n " ;
30
30
}
31
31
32
32
int main ()
33
33
{
34
- vector<int > vetor ;
34
+ vector<int > vector ;
35
35
for (uint32_t i = 0 ; i < 10 ; ++i)
36
36
{
37
- vetor .push_back (rand () % 100 );
37
+ vector .push_back (rand () % 100 );
38
38
}
39
- showVector (vetor );
40
- insertionSort (vetor );
41
- showVector (vetor );
39
+ showVector (vector );
40
+ insertionSort (vector );
41
+ showVector (vector );
42
42
}
You can’t perform that action at this time.
0 commit comments