Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Merge(int vet[], int primo, int ultimo){
- int dim1 = ultimo-primo+1;
- int med = (primo+ultimo)/2;
- int vetapp[dim1];
- int p = primo, u = med+1;
- for(int i = 0; i!=dim1; i++){
- if(p>med){
- vetapp[i] = vet[u];
- u++;
- }
- if(u>ultimo){
- vetapp[i] = vet[p];
- p++;
- }
- if(p<=med && u<=ultimo){
- if(vet[p] < vet[u]){
- vetapp[i] = vet[p];
- p++;
- }
- else{
- vetapp[i] = vet[u];
- u++;
- }
- }
- }
- for(int i = primo; i!=ultimo+1; i++){
- vet[i] = vetapp[i-primo];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement