O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Write a function imerge that gets pointers to two sorted integer array.docx

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Carregando em…3
×

Confira estes a seguir

1 de 2 Anúncio

Write a function imerge that gets pointers to two sorted integer array.docx

Baixar para ler offline

Write a function imerge that gets pointers to two sorted integer arrays src1[] and src2[] as parameters(the arrays are sorted in ascending order), merges the two arrays in ascending sorted order into a dynamic integer array dst[] and returns to dst[]
The function header is int* imerge (int * src1, int *src2)
Solution
#include <stdio.h>
#include <conio.h>
void main(){
int *arr,src1,src2,tmp,n;
int*imerge(int*src1,intsrc2)
clrscr();
printf(\"Enter how many data you want to sort : \");
scanf(\"%d\",&n);
for(src1=0;src1<nsrc1i++)
scanf(\"%d\",arr+src1);
for(src1=0;src1<n;src1++)
{
for(src2=src1+1;src2<n;src2++){
if( *(arr+src1) > *(arr+src2)){
tmp = *(arr+src1);
*(arr+src1) = *(arr+src2);
*(arr+src2) = tmp;
}
}
}
printf(\"\ \ After Sort\ \");
for(sr1=0;src1<n;src1++)
printf(\"%d\ \",*(arr+src1));
getch();
}
.

Write a function imerge that gets pointers to two sorted integer arrays src1[] and src2[] as parameters(the arrays are sorted in ascending order), merges the two arrays in ascending sorted order into a dynamic integer array dst[] and returns to dst[]
The function header is int* imerge (int * src1, int *src2)
Solution
#include <stdio.h>
#include <conio.h>
void main(){
int *arr,src1,src2,tmp,n;
int*imerge(int*src1,intsrc2)
clrscr();
printf(\"Enter how many data you want to sort : \");
scanf(\"%d\",&n);
for(src1=0;src1<nsrc1i++)
scanf(\"%d\",arr+src1);
for(src1=0;src1<n;src1++)
{
for(src2=src1+1;src2<n;src2++){
if( *(arr+src1) > *(arr+src2)){
tmp = *(arr+src1);
*(arr+src1) = *(arr+src2);
*(arr+src2) = tmp;
}
}
}
printf(\"\ \ After Sort\ \");
for(sr1=0;src1<n;src1++)
printf(\"%d\ \",*(arr+src1));
getch();
}
.

Anúncio
Anúncio

Mais Conteúdo rRelacionado

Semelhante a Write a function imerge that gets pointers to two sorted integer array.docx (20)

Mais de lez31palka (20)

Anúncio

Mais recentes (20)

Write a function imerge that gets pointers to two sorted integer array.docx

  1. 1. Write a function imerge that gets pointers to two sorted integer arrays src1[] and src2[] as parameters(the arrays are sorted in ascending order), merges the two arrays in ascending sorted order into a dynamic integer array dst[] and returns to dst[] The function header is int* imerge (int * src1, int *src2) Solution #include <stdio.h> #include <conio.h> void main(){ int *arr,src1,src2,tmp,n; int*imerge(int*src1,intsrc2) clrscr(); printf("Enter how many data you want to sort : "); scanf("%d",&n); for(src1=0;src1<nsrc1i++) scanf("%d",arr+src1); for(src1=0;src1<n;src1++) { for(src2=src1+1;src2<n;src2++){ if( *(arr+src1) > *(arr+src2)){ tmp = *(arr+src1); *(arr+src1) = *(arr+src2); *(arr+src2) = tmp; } } } printf(" After Sort "); for(sr1=0;src1<n;src1++) printf("%d ",*(arr+src1));
  2. 2. getch(); }

×