Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- typedef struct Aluno{
- int matricula;
- char nome[30];
- int idade;
- }Aluno;
- int Busca(Aluno L[],int *tamVet,Aluno x,int *PosIns);
- void InserePosicao(Aluno *L[],int *n,Aluno x,int PosIns);
- int main(void)
- {
- Aluno vetor;
- int n = 0;
- int PosIns = 0;
- int tamVet = 10;
- Aluno L[tamVet];
- }
- int Busca(Aluno L[],int *tamVet,Aluno x,int *PosIns){
- int inf,sup,m;
- inf = 0;
- sup = (*tamVet - 1);
- printf("%d\n%d\n",inf,sup);
- while(inf<=sup){
- m = ((inf + sup)/2);
- if(L[m].matricula == x.matricula){
- return m;
- }
- else if(L[m].matricula > x.matricula){
- inf = (m+1);
- }
- else{
- m = (m-1);
- }
- }
- *PosIns = inf;
- return 0;
- }
- void InserePosicao(Aluno *L[],int *n,Aluno x,int PosIns){
- int j;
- for(j=n;j>=PosIns;j--){
- L[j+1] = L[j];
- }
- *L[PosIns] = x;
- n++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement