Beispiel #1
0
int main()
{
	tree *arvore = criaVazia();

	//arvore = criaNo('M', criaNo('H', criaNo('E', criaNo('C', criaNo('A', criaVazia(), criaVazia()),criaNo('D', criaVazia(), criaVazia())), criaNo('G', criaVazia(), criaVazia())), criaNo('K', criaVazia(), criaNo('L', criaVazia(), criaVazia()))), criaNo('R', criaNo('O', criaNo('N', criaVazia(), criaVazia()), criaVazia()), criaNo('T', criaVazia(), criaVazia())));

	/* AROVRE */
	arvore = insereArv(arvore, 'M');

	arvore = insereArv(arvore, 'R');
	arvore = insereArv(arvore, 'H');

	arvore = insereArv(arvore, 'O');
	arvore = insereArv(arvore, 'K');
	arvore = insereArv(arvore, 'T');
	arvore = insereArv(arvore, 'E');

	arvore = insereArv(arvore, 'L');
	arvore = insereArv(arvore, 'G');
	arvore = insereArv(arvore, 'N');
	arvore = insereArv(arvore, 'C');

	arvore = insereArv(arvore, 'D');
	arvore = insereArv(arvore, 'A');
	/* AROVRE */

	imprimirArvore(arvore);

	printf("\n(M(H(E(C(A(_)(_))(D(_)(_)))(G(_)(_)))(K(_)(L(_)(_))))(R(O(N(_)(_))(_))(T(_)(_))))\n");

	printf("\n%d\n%d", 'H', 'X');

	printf("\nPertence H na arvore = %d", pertence(arvore, 'H'));
	printf("\nPertence X na arvore = %d\n", pertence(arvore, 'X'));

	/*tree *arvoreBusca = criaVazia();
	arvoreBusca = busca(arvore, 'C');

	imprimirArvore(arvoreBusca);*/

	/*arvore = removeArv(arvore, 'D');
	arvore = removeArv(arvore, 'K');
	arvore = removeArv(arvore, 'O');*/
	arvore = removeArv(arvore, 'M');

	imprimirArvore(arvore);

	return 0;
}
Beispiel #2
0
tSolucao solver (int solucaoParcial[], int posicao, int custoAtual) {

	tSolucao menorcustolocal = {MAXINT,{-1,-1,-1,-1,-1,-1,-1,-1}};
	int origem = solucaoParcial[posicao];
	int todas_cidades = 1;
	tSolucao temp = {MAXINT,{-1,-1,-1,-1,-1,-1,-1,-1}};
	int cidade, cidade_aux;

	for (cidade=1; cidade<N_CIDADES; cidade++) {
		if ( !pertence(cidade, solucaoParcial, posicao) ) {
			todas_cidades = 0;
			printf("Cid: %d, Pos: %d ", cidade, posicao+1 );
			solucaoParcial [posicao+1] = cidade;
			temp = solver(solucaoParcial, posicao+1, custoAtual+custo[origem][cidade]);
			//if ( (temp < menorcustolocal) && ((posicao+1) == (N_CIDADES-1)) )
			if (temp.custo < menorcustolocal.custo)
			{
				menorcustolocal.custo = temp.custo;
                for (cidade_aux =0; cidade_aux < N_CIDADES; cidade_aux++)
                    menorcustolocal.cidades[cidade_aux]=temp.cidades[cidade_aux];
			}
		}
	}
	if (todas_cidades == 1)
    {
        menorcustolocal.custo = custoAtual + custo[origem][0];
        for (cidade =0; cidade < N_CIDADES; cidade++)
            menorcustolocal.cidades[cidade]=solucaoParcial[cidade];
    }
    return menorcustolocal;
}
Beispiel #3
0
//avore geradora minima PRIM
void algoritimo_prim(grafo *G, int *d, int *pai, int *key){
	no *q;
	aresta *p;
	grafo Q;

	define(&Q);
	int maior, r;
	maior=buscamaior(G);
	int weight[maior][maior];
	//cria matriz de peso
	q=G->inicio;
	r=q->vertice;
	while(q!=NULL){
		if(q->prox_aresta!=NULL){
			p=q->prox_aresta;
			while(p!=NULL){
				weight[q->vertice][p->arestas]=p->custo;
				p=p->prox_aresta;
			}
		}
		q=q->prox;
	}
	// termina criar matriz

	q=G->inicio;
	while(q!=NULL){
		key[q->vertice]=9999;
		pai[q->vertice]=-1;
		enfila(&Q, q->vertice);
		q=q->prox;
	}
	key[r]=0;

	int u=buscaminimo(&Q, key);
	q=NULL;
	if(u!=-1){
		q=buscavertice(G,u);
	}

	while(q!=NULL){
		p=q->prox_aresta;
		while(p!=NULL){
			if(pertence(&Q,p->arestas)==1 && weight[q->vertice][p->arestas]<key[p->arestas]){
				pai[p->arestas]=q->vertice;
				key[p->arestas]=weight[q->vertice][p->arestas];
			}
			p=p->prox_aresta;
		}
		u=buscaminimo(&Q, key);
		q=NULL;
		if(u!=-1){
			q=buscavertice(G,u);
		}

	}

}
Beispiel #4
0
int pertence(tree *arv, char letra)
{
	if(arv->dado == letra)
	{
		return 1;
	}
	else if(arv->esq != NULL && letra < arv->dado)
	{
		return pertence(arv->esq, letra);
	}
	else if(arv->dir != NULL && letra > arv->dado)
	{
		return pertence(arv->dir, letra);
	}
	else
	{
		return 0;
	}
}
int gera_entrada(FILE *arquivo)
{
	int nro_entradas,tam_alfabeto,nro_subconj,tam_subconj,cont,flag,elem,i,indice,chuchu;
	int *alfabeto,*conj;	
	arquivo = fopen("entrada.txt","a");
	nro_entradas = rand()%10;	
	

	for(i=0;i<nro_entradas;i++)
	{
		fprintf(arquivo,"%s","inicio");	
		cont = 0;
		tam_alfabeto = rand()%8;
		alfabeto = malloc((tam_alfabeto+1)*sizeof(int)); //+1 pq a primeira posicao eh o tamanho dele
		alfabeto[0] = tam_alfabeto;
		
		while(cont != tam_alfabeto)
		{
			//flag = 0;
			elem = rand()%20;			//elemento do alfabeto
			
			if(pertence(elem,alfabeto,tam_alfabeto))
			{
				insere(elem,alfabeto,tam_alfabeto);
				cont++;
			}		
		}
		ordena(alfabeto,tam_alfabeto); //alfabeto vai estar em ordem crescente
		fprintf(arquivo,"\n");
		for(indice=0; indice < tam_alfabeto+1;indice++)
			fprintf(arquivo,"%d ",alfabeto[indice]);				
				
		nro_subconj = rand()%20;
		fprintf(arquivo,"\nnro de subconj=%d \n",nro_subconj);

		for(indice=0;indice<nro_subconj;indice++)
		{
			tam_subconj = rand()%tam_alfabeto;
			conj = gera_conjunto(alfabeto,tam_subconj,tam_alfabeto);
			
			for(chuchu=0;chuchu<tam_subconj+1;chuchu++)
			{
				fprintf(arquivo,"%d ",conj[chuchu]);
			}
			fprintf(arquivo,"\n");

		}

	}
	free(alfabeto);
	free(conj);
	fprintf(arquivo,"\nfim");
	fclose(arquivo);
}
Beispiel #6
0
int main(int argc, char **argv)
{
	no *n;
	lista *l;
	lista *l2;
	lista *l3;
	int i,k;
	l = criaLista();
	l2 = criaLista();
	l3 = criaLista();
	
	for(i = 1 ; i < 5 ; i++){
			n = criaNo(i);
			insereFim(l,n);
		}
	for(i = 2 ; i < 6 ; i++){
			n = criaNo(i);
			insereFim(l2,n);
		}
	printf("\n **lista ** \n");
	imprimeLista(l);
	
	printf("\n **lista 2** \n");
	imprimeLista(l2);
	
	printf("\n **uniao ** \n");
	uniao(l,l2,l3);
	imprimeLista(l3);
	liberaLista(l3);
	l3 = criaLista();
	
	printf("\n **intersecao ** \n");
	intersecao(l,l2,l3);
	imprimeLista(l3);
	
	k = pertence(l,l2);
	printf("\n \n 0 - NAO \n 1 - SIM \n");
	printf("pertence: %d \n",k);
	
	liberaLista(l);
	liberaLista(l2);
	liberaLista(l3);
	return 0;
}
Beispiel #7
0
int NovoPaciente()
   {
   char resposta[2];
   int  delta_x, delta_y;
   char *p_ch;

   delta_x  = (int) ((MAXX * 35L)/100);
   delta_y  = (int) ((MAXY * 15L)/100);

   CriaJanelaGrafica(
		       M_PADRAO,
		       (MAXX       - delta_x)/2,
		       (int) ((MAXY * 85L)/100 - delta_y/2),
		       (MAXX       + delta_x)/2,
		       (int) ((MAXY * 85L)/100 + delta_y/2),
		       0,
		       ""
		    );

   AtivaJanelaGrafica(M_PADRAO,0);
   setcolor (bea_color[14]);

   clearviewport();

   Moldura();

   p_ch = "NOVO PACIENTE (S/N) ? ";
   setcolor(bea_color[14]);
   gprintf( DELTA_X(50) - (textwidth(p_ch))/2, DELTA_Y(50), p_ch);
   do {
      LEITURA (  'c',
		 DELTA_X(50) + (textwidth(p_ch))/2,
		 DELTA_Y(50),
		 resposta,
		 1,
		 0,
		 0  );
      } while (resposta[0]!='S' && resposta[0]!='N' && resposta[0]!=ESC);

   if (*resposta==ESC) return(FALSE);
   if (pertence(*resposta,"Ss"))
      {
      LeData();
      FlagIntegridade=FALSE;
      FlagComent=FALSE;
      zeraPaciente();
      ZeraProvas();
      *PacienteIdade=NULL;
      *medico=NULL;
      *servico=NULL;
      *institu=NULL;
      *IouA=NULL;
      *justif=NULL;
      *temdiag=NULL;
      *diagnost=NULL;
      *RiscoCir=NULL;
      *TosseOuExpec = NULL;
      *comentario=NULL;
      SupCorp=0.0;
      *Temperatura = NULL;
      VAR_RESP = FALSE;
      VolumePulmTotal = 0.0;
      VolumePulmTotalteorico = 0.0;
      VARteorico = 0.0;

      return(TRUE);
      }
   else
      return(FALSE);

   }/* End of NovoPaciente () */
Beispiel #8
0
void AmbientePaciente (void)
   {
   register  int  delta_x, delta_y;
   char           *p_ch, id;


   delta_x = (int) ((MAXX * 15L) / 1000);
   delta_y = (int) ((MAXY * 17L) / 1000);


   p_ch = "ENTRADA DE DADOS DO PACIENTE";
   CriaJanelaGrafica ( DADOSPAC,
		       delta_x,
		       delta_y,
		       MAXX - delta_x,
		       MAXY - delta_y,
		       0,
		       p_ch );

   setcolor(bea_color[10]);

   setviewport ( delta_x, delta_y, MAXX - delta_x, MAXY - delta_y, 1 );

   Moldura ();

   AtivaJanelaGrafica(DADOSPAC, 0);
   setcolor (bea_color[14]);

   getviewsettings ( &vp );

   gprintf( DELTA_X ( 5), DELTA_Y ( 5), "NOME: %s", Paciente.Nome);

   id = Paciente.Prontuario[7];
   Paciente.Prontuario[7] = '\0';
   gprintf( DELTA_X ( 5), DELTA_Y (10),
	   "No DO PRONTUARIO: %7s %c",
	   Paciente.Prontuario, id);

   Paciente.Prontuario[7] = id;


   gprintf( DELTA_X ( 5), DELTA_Y (15), "SEXO: " );

   if (*Paciente.Sexo != NULL)
      {
      outtextxy( DELTA_X ( 5) + textwidth("SEXO: "), DELTA_Y (15),
		 Paciente.Sexo[0] == 'M' ? "Masculino" : " Feminino");
      }


   gprintf( DELTA_X ( 5), DELTA_Y (20),
	   "DATA DE NASCIMENTO: %2s/%2s/%2s",Paciente.Dia,Paciente.Mes,Paciente.Ano);

   if (*PacienteIdade!=NULL)
      {
      gprintf( DELTA_X (50), DELTA_Y (20),
		"IDADE: %2s Anos", PacienteIdade);
      }
   else
      {
      gprintf( DELTA_X (50), DELTA_Y (20),
		"IDADE:    Anos" );
      }

   gprintf( DELTA_X ( 5), DELTA_Y (25),
	    "ADULTO ou CRIANCA ? (A/C): " );

   if (*Paciente.Fase != NULL)
      {
      outtextxy( DELTA_X ( 5) + textwidth ("ADULTO ou CRIANCA ? (A/C): "),
		 DELTA_Y (25),
		 Paciente.Fase[0]=='A' ? " Adulto" : "Crianca");
      }

   gprintf( DELTA_X ( 5), DELTA_Y (30),
	    "ALTURA (cm): %s", Paciente.Altura);

   gprintf( DELTA_X ( 5), DELTA_Y (35),
	    "PESO (Kg): %s", Paciente.Peso);

   if (SupCorp > 0.0)
     {
     gprintf( DELTA_X (50),
	      DELTA_Y (35),
	      "SUPERFICIE CORPORAL: %-5.2f", SupCorp);
     }
   else
     {
     gprintf( DELTA_X (50),
	      DELTA_Y (35),
	      "SUPERFICIE CORPORAL:       " );
     }


   gprintf( DELTA_X ( 5), DELTA_Y (40),
	    "FUMANTE ? (S/N/E): %s", Paciente.Fumante);

   if      (pertence(Paciente.Fumante[0],"Ss"))
      {
      gprintf( DELTA_X (50), DELTA_Y (40),
	       "HA QUANTOS ANOS ? : %s", Paciente.tempfumo);

      gprintf( DELTA_X (50), DELTA_Y (43),
	       "No CIGARROS/DIA   : %s",Paciente.cigardia);
      }
   else if (pertence(Paciente.Fumante[0],"Ee"))
      {
      gprintf( DELTA_X (50), DELTA_Y (40),
	       "HA QUANTO TEMPO PAROU ? : "" %2s ANOS  %2s MESES",Paciente.deixfumoA,Paciente.deixfumoM);

      gprintf( DELTA_X (50), DELTA_Y (43),
	       "QUANTOS ANOS FUMOU ? : %2s", Paciente.tempfumo);

      gprintf( DELTA_X (50), DELTA_Y (46),
	       "No CIGARROS/DIA : %2s", Paciente.cigardia);
      }

   p_ch = "TOSSE OU EXPECTORACAO (S/N): %s";
   gprintf( DELTA_X ( 5), DELTA_Y (45),
	    p_ch, TosseOuExpec );

   gprintf( DELTA_X ( 5), DELTA_Y (50),
	    "CONVENIO: %s", institu);

   gprintf( DELTA_X ( 5), DELTA_Y (55),
	    "PACIENTE INTERNO OU AMBULATORIAL ? (I/A): %s", IouA);

   gprintf( DELTA_X ( 5), DELTA_Y (60),
	    "JUSTIFICATIVA PARA O EXAME: %s", justif);

   gprintf( DELTA_X ( 5), DELTA_Y (65),
	    "MEDICO REQUISITANTE: %s", medico);

   gprintf( DELTA_X ( 5), DELTA_Y (70),
	    "SERVICO REQUISITANTE: %s", servico);

   gprintf( DELTA_X ( 5), DELTA_Y (75),
	    "PACIENTE COM ALGUM DIAGNOSTICO DE DOENCA PULMONAR ? (S/N): %s", temdiag);



   if (pertence ( temdiag[0], "Ss" ))
      {
      gprintf( DELTA_X ( 5), DELTA_Y (80),
	       "DIAGNOSTICO: %s", diagnost);
      }

   if ( (*RiscoCir == '1') ||
	(*RiscoCir == '2') ||
	(*RiscoCir == '3') )
      {
      p_ch = "S";
      }
   else
      {
      p_ch = "";
      }


   gprintf( DELTA_X ( 5), DELTA_Y (85),
	    "CIRURGIA PREVISTA - ESTIMATIVA DO RISCO CIRURGICO ? (S/N): %s", p_ch);


   if (*RiscoCir != NULL)
      {
      gprintf( DELTA_X ( 5),
	       DELTA_Y (90),
	       "CIRURGIA: (1 - ABDOMINAL ALTA  2 - TORACICA  3 - OUTRA): %s",
	       RiscoCir );
      }

   }  /* AmbientePaciente */
Beispiel #9
0
void DadosPaciente()
   {
   char                  Resposta[2];
   char                        t[46];
   char                        *p_ch;
   int            li, co, li_1, co_1,
		  li_2, co_2, cor;


   t[0] = NULL;

   if (Primpac && !DadosPacienteOk)
      {
      novopac = TRUE;
      Primpac = FALSE;
      }
   else     novopac = NovoPaciente();

   AmbientePaciente();

   setcolor (bea_color[15]);

   getviewsettings ( &vp );

   do {
      /* ============ ENTRADA DO NOME DO PACIENTE ============== */
      do {
	 strcpy( t, Paciente.Nome );

	 LEITURA(  'c',
		   textwidth("NOME: ") + DELTA_X ( 5), DELTA_Y ( 5),
		   Paciente.Nome, 45, 0L, 0L  );

	 if (Paciente.Nome[0] == ESC)
	    {
	    if (novopac)
	       {  /* Se ja tinha pac mas queria inserir outro */
	       zeraPaciente();
	       novopac=FALSE;
	       Primpac=TRUE;
	       }
	    else
	       {
	       strcpy(Paciente.Nome, t);
	       return;
	       } /* devolve nome original */
	    }
	 } while (*Paciente.Nome == NULL);



      do {
	 /* ========= ENTRADA DO No PRONTUARIO DO PACIENTE ============== */
	 strcpy( t, Paciente.Prontuario );

	 LEITURA(  'n',
		   textwidth("No DO PRONTUARIO: ") + DELTA_X (5), DELTA_Y (10),
		   Paciente.Prontuario, 7, 0L, MAXLONG );

	 if (Paciente.Prontuario[0] == ESC)
	    {
	    if (novopac)
	       { /* Se ja tinha pac mas queria inserir outro */
	       zeraPaciente();
	       novopac=FALSE;
	       Primpac=TRUE;
	       }
	    else
	       {
	       strcpy(Paciente.Prontuario, t);
	       return;
	       } /* devolve nome original */
	    }

	 LEITURA(  'n',
		   textwidth("No DO PRONTUARIO: 1234567 ") +
		   DELTA_X ( 5), DELTA_Y (10),
		   digito, 1, 0L, 9L);

	 if (digito[0] == ESC)
	    {
	    if (novopac)
	       {      /* Se ja tinha pac mas queria inserir outro */
	       zeraPaciente();
	       novopac=FALSE;
	       Primpac=TRUE;
	       }
	    else
	       {
	       strcpy(Paciente.Prontuario, t);
	       return;
	       } /* devolve nome original */
	    }

	 strcat(Paciente.Prontuario,digito);

	 } while (*Paciente.Prontuario == NULL);

      /* ========= ENTRADA DO SEXO DO PACIENTE ============== */
      strcpy( t, Paciente.Sexo );
      co  = textwidth("SEXO: ") + DELTA_X ( 5);
      li  = DELTA_Y (15);

      do {
	 LEITURA(  'c',
		   co,
		   li,
		   Paciente.Sexo,1,0L,0L);

	 if (Paciente.Sexo[0] == ESC)
	    {
	    if (novopac)
	       { /* Se ja tinha pac mas queria inserir outro */
	       zeraPaciente();
	       novopac=FALSE;
	       Primpac=TRUE;
	       }
	    else
	       {
	       strcpy(Paciente.Sexo,t);
	       return; /* devolve nome original */
	       }
	    }

	 ApagaWord(co, li, 8);

	 } while ( (Paciente.Sexo[0] != 'M') &&
		   (Paciente.Sexo[0] != 'F')    );

      if ( Paciente.Sexo[0] != 'M' )  outtextxy(co, li, " Feminino" );
      else                            outtextxy(co, li, "Masculino");


      /* ========= ENTRADA DA DATA DE NASCIMENTO ================ */
      strcpy( t, Paciente.Dia );
      co  = textwidth("DATA DE NASCIMENTO: ") + DELTA_X ( 5);
      li  = DELTA_Y (20);
      do {
	 LEITURA(  'n',
		   co,
		   li,
		   Paciente.Dia, 2, 1L, 31L);

	 if (Paciente.Dia[0] == ESC)
	    {
	    if (novopac)
	       { /* Se ja tinha pac mas queria inserir outro */
	       zeraPaciente();
	       novopac = FALSE;
	       Primpac = TRUE;
	       }
	    else
	       {
	       strcpy(Paciente.Dia,t);
	       return;
	       } /* devolve nome original */
	    }
	 } while (Paciente.Dia == NULL);

      chama( Paciente.Dia, co, li );


      co += textwidth("00/");
      strcpy( t, Paciente.Mes );
      do {
	 LEITURA(  'n',
		   co,
		   li,
		   Paciente.Mes,2,1L,12L);

	 if (Paciente.Mes[0]==ESC)
	    {
	    if (novopac)
	       { /* Se ja tinha pac mas queria inserir outro */
	       zeraPaciente();
	       novopac=FALSE;
	       Primpac=TRUE;
	       }
	    else
	       {
	       strcpy( Paciente.Mes, t );
	       return;
	       } /* devolve nome original */
	    }
	  } while (Paciente.Mes==NULL);

      chama(Paciente.Mes, co, li);


      co += textwidth("00/");
      strcpy(t,Paciente.Ano);
      do {
	 LEITURA(  'n',
		   co,
		   li,
		   Paciente.Ano,2,1L,99L);

	 if (Paciente.Ano[0]==ESC)
	    {
	    if (novopac)
	       { /* Se ja tinha pac mas queria inserir outro */
	       zeraPaciente();
	       novopac=FALSE;
	       Primpac=TRUE;
	       }
	    else
	       {
	       strcpy(Paciente.Ano,t);
	       return;
	       } /* devolve nome original */
	    }

	 chama(Paciente.Ano, co, li);

	 CalculaIdade();

	 ApagaWord( DELTA_X (50) + textwidth("IDADE: "), li, 2  );

	 gprintf  ( DELTA_X (50) + textwidth("IDADE: "), li, "%2s", PacienteIdade);

	 } while ( (atoi(PacienteIdade) <  5) ||
		   (atoi(PacienteIdade) > 90)    );


	co  = textwidth("ADULTO ou CRIANCA ? (A/C): ") + DELTA_X ( 5);
	li  = DELTA_Y (25);
	if ( (atoi(PacienteIdade) < 17) && (atoi(PacienteIdade) > 14) )
	   {
	   do{

	     LEITURA(  'c',
		       co,
		       li,
		       Paciente.Fase,1,0L,0L);

	     } while ( (Paciente.Fase[0] != 'A') &&
		       (Paciente.Fase[0] != 'C')    );


	   ApagaWord( co, li, 7 );
	   if (pertence(Paciente.Fase[0],"Aa" ))
	     {
	     outtextxy( co, li, " Adulto");
	     }
	   else
	     {
	     outtextxy( co, li, "Crianca");
	     }
	   }
	else
	   {
	   if (atoi(PacienteIdade) <= 14)   *Paciente.Fase='C';
	   else                             *Paciente.Fase='A';

	   ApagaWord( co, li, 7 );

	   if (Paciente.Fase[0] == 'A') gprintf( co, li, " Adulto");
	   else  	                gprintf( co, li, "Crianca");
	   }

	/* ========= ENTRADA DA ALTURA  =============== */

	co_1 = co;
	li_1 = li;

	co  = textwidth("ALTURA (cm): ") + DELTA_X ( 5);
	li  = DELTA_Y (30);
	LEITURA('n', co, li, Paciente.Altura, 3, 110L, 210L);

	if (Paciente.Altura[0] == ESC)
	  {
	  if (novopac)
	     { /* Se ja tinha pac mas queria inserir outro */
	     zeraPaciente();
	     novopac=FALSE;
	     Primpac=TRUE;
	     }
	  else
	     {
	     strcpy(Paciente.Altura,t);
	     return;
	     } /* devolve nome original */
	  }

	if (atoi(Paciente.Altura) > 170)
	   {
	   *Paciente.Fase='A';
	   ApagaWord(co_1, li_1, 7);
	   gprintf(co_1, li_1, " Adulto");
	   }

	/* ========= ENTRADA DO PESO  =============== */

	co  = textwidth("PESO (Kg): ") + DELTA_X ( 5);
	li  = DELTA_Y (35);

	LEITURA('n',co, li, Paciente.Peso, 3, 16L, 150L);
	if (Paciente.Peso[0] == ESC)
	   {
	   if (novopac)
	      {      /* Se ja tinha pac mas queria inserir outro */
	      zeraPaciente();
	      novopac = FALSE;
	      Primpac = TRUE;
	      }
	   else {
		strcpy(Paciente.Peso,t);
		return;
		} /* devolve nome original */
	   }

	CalculaSupCorporea();

	co_1 = DELTA_X (50) + textwidth("SUPERFICIE CORPORAL: ");


	ApagaWord( co_1, li, 5);


	gprintf(co_1, li, "%-5.2f", SupCorp);



	/* ========= ENTRADA DE SE FUMANTE =============== */

	co  = textwidth("FUMANTE ? (S/N/E): ") + DELTA_X ( 5);
	li  = DELTA_Y (40);

	if ( test(  'c',co, li, Paciente.Fumante , 1, 0L, 0L));
	else return;


	co   = DELTA_X (50);
	li   = DELTA_Y (40);
	li_1 = DELTA_Y (43);
	li_2 = DELTA_Y (46);


	ApagaWord( co,   li, 38 );
	ApagaWord( co, li_1, 25 );
	ApagaWord( co, li_2, 25 );

	if      (pertence(Paciente.Fumante[0],"Ss"))
	   {
	   co   = DELTA_X (50) + textwidth("HA QUANTOS ANOS ? : ");
	   co_1 = DELTA_X (50) + textwidth("No CIGARROS/DIA   : ");
	   co_2 = DELTA_X (50);

	   cor  =  getcolor();
	   setcolor( bea_color[14] );
	   gprintf(co_2, li  ,"HA QUANTOS ANOS ? : ");
	   gprintf(co_2, li_1,"No CIGARROS/DIA   : ");

	   setcolor(cor);

	   gprintf(co  , li  ,"%s", Paciente.tempfumo);
	   gprintf(co_1, li_1,"%s", Paciente.cigardia);


	   LEITURA('n',co  , li  , Paciente.tempfumo, 2, 1L, 99L);
	   LEITURA('n',co_1, li_1, Paciente.cigardia, 2, 1L, 99L);
	   }
	else if (pertence(Paciente.Fumante[0],"Ee"))
	   {
	   cor  =  getcolor();
	   setcolor( bea_color[14] );
	   gprintf(co, li  , "HA QUANTO TEMPO PAROU ? : ""    ANOS ");
	   gprintf(co, li_1, "QUANTOS ANOS FUMOU ? :   ");
	   gprintf(co, li_2, "No CIGARROS/DIA :   ");

	   setcolor(cor);

	   co   = DELTA_X (50) + textwidth("HA QUANTO TEMPO PAROU ? : ");
	   co_1 = DELTA_X (50) + textwidth("QUANTOS ANOS FUMOU ? : ");
	   co_2 = DELTA_X (50) + textwidth("No CIGARROS/DIA : ");

	   gprintf(co  , li  , "%s", Paciente.deixfumoA );
	   gprintf(co_1, li_1, "%s", Paciente.tempfumo );
	   gprintf(co_2, li_2, "%s", Paciente.cigardia );

	   LEITURA('n', co  , li  , Paciente.deixfumoA, 2, 1L, 99L);
	   LEITURA('n', co_1, li_1, Paciente.tempfumo , 2, 1L, 99L);
	   LEITURA('n', co_2, li_2, Paciente.cigardia , 2, 1L, 99L);
	   }




	/* ========= ENTRADA DOS DADOS RESTANTES ========= */


	p_ch = "TOSSE OU EXPECTORACAO (S/N): ";
	co   = DELTA_X ( 5) + textwidth (p_ch);
	li   = DELTA_Y (45);
	do
	   LeituraC( co, li, TosseOuExpec, "SsNn" );
	while (*TosseOuExpec == '\0');

	p_ch = "CONVENIO: ";
	co   = DELTA_X ( 5) + textwidth (p_ch);
	li   = DELTA_Y (50);
	Leitura  ( co, li, institu, 45  );

	p_ch = "PACIENTE INTERNO OU AMBULATORIAL ? (I/A): ";
	LeituraC ( DELTA_X ( 5) + textwidth (p_ch), DELTA_Y (55), IouA, "IiAa" );

	p_ch = "JUSTIFICATIVA PARA O EXAME: ";
	co   = DELTA_X ( 5) + textwidth (p_ch);
	li   = DELTA_Y (60);
	Leitura  ( co, li, justif, 32);

	p_ch = "MEDICO REQUISITANTE: ";
	co   = DELTA_X ( 5) + textwidth (p_ch);
	li   = DELTA_Y (65);
	Leitura( co, li, medico, 38  );

	p_ch = "SERVICO REQUISITANTE: ";
	co   = DELTA_X ( 5) + textwidth (p_ch);
	li   = DELTA_Y (70);
	Leitura( co, li, servico, 38  );

	p_ch = "PACIENTE COM ALGUM DIAGNOSTICO DE DOENCA PULMONAR ? (S/N): ";
	LeituraC( DELTA_X ( 5) + textwidth (p_ch), DELTA_Y (75), temdiag, "SsNn" );


	if (pertence(temdiag[0], "Ss" ))
	   {
	   cor = getcolor();
	   setcolor(bea_color[14]);

	   p_ch = "DIAGNOSTICO: ";
	   gprintf( DELTA_X ( 5), DELTA_Y (80), p_ch );

	   setcolor(cor);

	   Leitura( DELTA_X ( 5) + textwidth (p_ch), DELTA_Y (80), diagnost, 30 );

	   }
	 else
	   {
	   ApagaWord( DELTA_X ( 5), DELTA_Y (80), 45 );
	   }

	cor = getcolor();
	setcolor(bea_color[14]);
	p_ch = "CIRURGIA PREVISTA - ESTIMATIVA DO RISCO CIRURGICO ? (S/N): ";
	gprintf( DELTA_X ( 5), DELTA_Y (85), p_ch );
	setcolor(cor);
	LeituraC( DELTA_X ( 5) + textwidth (p_ch), DELTA_Y (85), RiscoCir, "SsNn" );

	if ( (RiscoCir[0] == 'N') || (RiscoCir[0] == 'n') ) *RiscoCir = NULL;

	if ( *RiscoCir != NULL )
	   {
	   cor = getcolor();
	   setcolor (bea_color[14]);

	   p_ch = "CIRURGIA: (1 - ABDOMINAL ALTA  2 - TORACICA  3 - OUTRA): ";
	   gprintf( DELTA_X ( 5), DELTA_Y (90), p_ch );
	   setcolor (cor);
	   LeituraC( DELTA_X ( 5) + textwidth (p_ch), DELTA_Y (90), RiscoCir, "123" );
	   }
	else
	   {
	   ApagaWord( DELTA_X ( 5), DELTA_Y (90), 75 );

	   ApagaWord( DELTA_X ( 5), DELTA_Y (95), 18 );

	   }

	Resposta[0] = 'S';
	Resposta[1] = NULL;

	cor = getcolor();
	setcolor (bea_color[12]);

	p_ch = "Dados Corretos ? (S/N) ";
	co   = DELTA_X(50) - (textwidth(p_ch))/2;
	co_1 = DELTA_X(50) + (textwidth(p_ch))/2;
	li   = DELTA_Y(95);


	outtextxy( co, li, p_ch );

	setcolor (cor);

	LeituraC( co_1, li, Resposta, "SsNn");

	ApagaWord( co, li, 25 );


      } while ( pertence(*Resposta,"Nn") );



   CalculaCVteorico();

   CalculaVVMteorico();

   CalculaFLUXteorico();

   DadosPacienteOk = TRUE;

   if (novopac)      ZeraProvas();

   } /* End of DadosPaciente() */
Beispiel #10
0
void Padrao(void)
	{
	int  delta_x, delta_y;
	char *p_ch;

	char padrao_i[1], laudo_i[1], cor_i[1];
#ifndef VERSAO_3.2
	char impressora_i[1];
#endif  VERSAO_3.2


	cleardevice ();

	delta_x  = PER_X (60);
	delta_y  = PER_Y (30);

	CriaJanelaGrafica(
			    M_PADRAO,
			    (MAXX - delta_x)/2,
			    (MAXY - delta_y)/2,
			    (MAXX + delta_x)/2,
			    (MAXY + delta_y)/2,
			    0,
			    "CONFIGURACAO"
			 );

	AtivaJanelaGrafica(M_PADRAO,0);
	setcolor ( bea_color[14] );
	Moldura();

#if     0
	gprintf(10,80,"DIGITE <S> PARA QUE AS MEDIDAS UTILIZEM OS CALCULOS");
	gprintf(10,90,"COM FORMULAS ESPECIFICAS PARA A POPULACAO ");
	gprintf(10,100,"BRASILEIRA DE ACORDO COM O PADRAO DE PEREIRA. ");
	gprintf(10,130,"DIGITE <N> PARA UTILIZAR OS PADROES AMERICANOS. ");
	gprintf(10,140,"DE MORRIS E KNUDSON.");
#endif  0

	p_ch = "Padrao Pereira (S/N) ? ";
	gprintf( DELTA_X(50) - (textwidth(p_ch))/2, DELTA_Y(10), p_ch);

	do{
	   LEITURA('c',
		   DELTA_X(50) + (textwidth(p_ch))/2, DELTA_Y(10),
		   padrao_i, 1, 0, 0);
	}while(!pertence(*padrao_i,"SsNn"));



#if     0
	gprintf(10,80,"DIGITE <S> PARA VISUALIZAR UM LAUDO NO FINAL DAS");
	gprintf(10,90,"PROVAS. CASO CONTRARIO, DIGITE <N>.");
#endif  0

	p_ch = "Com Laudo (S/N) ? ";
	outtextxy( DELTA_X(50) - (textwidth(p_ch))/2, DELTA_Y(30), p_ch);
	do{
	   LEITURA('c',
		   DELTA_X(50) + (textwidth(p_ch))/2, DELTA_Y(30),
		   laudo_i, 1, 0, 0);
	}while(!pertence(*laudo_i,"SsNn"));

#if     0
	gprintf(10,80,"DIGITE <S> PARA VISUALIZAR O BEATRICE COM CORES ");
	gprintf(10,90,"SE QUISER PRETO E BRANCO DIGITE <N>.");
#endif  0

	p_ch = "Monitor Colorido (S/N) ? ";
	outtextxy( DELTA_X(50) - (textwidth(p_ch))/2, DELTA_Y(50), p_ch);

	do{
	   LEITURA('c',
		   DELTA_X(50) + (textwidth(p_ch))/2, DELTA_Y(50),
		   cor_i, 1, 0, 0);
	}while(!pertence(*cor_i,"SsNn"));

#if     0
	gprintf(10,80,"DIGITE <E> PARA IMPRESSORAS PADRAO EPSON OU SEJA");
	gprintf(10,90,"MATRICIAIS, SE FOR DESKJET DIGITE <D>, OU LASER <L>.");
#endif  0


#ifndef VERSAO_3.2

	p_ch = "Impressora (E)Epson/(M)HP Mono/(C)HP Color ? ";
	outtextxy(DELTA_X(50) - (textwidth(p_ch))/2, DELTA_Y(70), p_ch);

	do {
	   LEITURA( 'c',
		    DELTA_X(50) + (textwidth(p_ch))/2, DELTA_Y(70),
		    impressora_i, 1, 0, 0);
	   }while(!pertence(*impressora_i,"EeMmCc"));

	switch (*impressora_i)
	   {
	   case 'E':
	   case 'e':Printer=PRT_EPSON_01_;
		    break;

	   case 'M':
	   case 'm':Printer=PRT_PCL_01_;
		    break;

	   case 'C':
	   case 'c':Printer=PRT_PCL_02_;
		    break;
	   }

	PrinterPort = 0;

#endif  VERSAO_3.2


	Cores   = (*cor_i == 'S')     ? TRUE : FALSE;
	Pereira = (*padrao_i == 'S')  ? TRUE : FALSE;
	Laudo   = (*laudo_i == 'S')   ? TRUE : FALSE;

	grava_padrao();


	if ( (Cores != TRUE) || (GraphDriver == HERCMONO) )
	   {
	   bea_color[ 0]   =   BLACK;
	   bea_color[ 1]   =   WHITE;
	   bea_color[ 2]   =   WHITE;
	   bea_color[ 3]   =   WHITE;
	   bea_color[ 4]   =   WHITE;
	   bea_color[ 5]   =   WHITE;
	   bea_color[ 6]   =   WHITE;
	   bea_color[ 7]   =   WHITE;
	   bea_color[ 8]   =   WHITE;
	   bea_color[ 9]   =   WHITE;
	   bea_color[10]   =   WHITE;
	   bea_color[11]   =   WHITE;
	   bea_color[12]   =   WHITE;
	   bea_color[13]   =   WHITE;
	   bea_color[14]   =   WHITE;
	   bea_color[15]   =   WHITE;
	   }
	else
	   {
	   bea_color[ 0]   =   BLACK;
	   bea_color[ 1]   =   BLUE;
	   bea_color[ 2]   =   GREEN;
	   bea_color[ 3]   =   CYAN;
	   bea_color[ 4]   =   RED;
	   bea_color[ 5]   =   MAGENTA;
	   bea_color[ 6]   =   BROWN;
	   bea_color[ 7]   =   LIGHTGRAY;
	   bea_color[ 8]   =   DARKGRAY;
	   bea_color[ 9]   =   LIGHTBLUE;
	   bea_color[10]   =   LIGHTGREEN;
	   bea_color[11]   =   LIGHTCYAN;
	   bea_color[12]   =   LIGHTRED;
	   bea_color[13]   =   LIGHTMAGENTA;
	   bea_color[14]   =   YELLOW;
	   bea_color[15]   =   WHITE;
	   }


	if  (DadosPacienteOk == TRUE)
	   {
	   CalculaCVteorico();
	   CalculaVVMteorico();
	   CalculaFLUXteorico();
	   }

	}  /* End of Padrao () */
Beispiel #11
0
int main(void){
	grafo G, lista;
	define(&G);
	define(&lista);

	char entrada='N'; 
	int data, data2;
	while(entrada!='@'){
		//interface
		printf("inserir vertice: (V)\n");
		printf("inserir aresta: (A)\n");
		printf("insere aresta ordenada: (o)\n");
		printf("visualizar grafo: (G)\n");
		printf("remover vertice: (R)\n");
		printf("remover aresta: (r)\n");
		printf("busca em largura: (l)\n");
		printf("busca em profundidade: (p)\n");
		printf("retorna Grau da porra tudo: (g)\n");
		printf("diz se grafo e conexo: (c)\n");
		printf("transforma em matriz de  adjacencia: (m)\n");
		printf("algoritmo de prim: (i)\n");
		printf("algoritmo djikistra: (d)\n");
		printf("ensira -1 para sair de qualquer opcao:\n");
		printf("sair: (@)\n");
		scanf(" %c",&entrada);
		//logica do programa
		if(entrada=='V'){
			printf("ensira vertice que deseja: \n");
			scanf("%d",&data);
			while(data!=-1){
				insere_vertice(&G,data);
				scanf("%d",&data);
			}
		}
		else if(entrada=='A'){
			printf("ensira a aresta, vertice e o custo que deseja ligar:\n");
			int custo;
			scanf("%d %d %d",&data,&data2,&custo);
			while(data!=-1){
				insere_aresta(&G,data,data2,custo);
				insere_aresta(&G,data2,data,custo);
				scanf("%d %d %d",&data,&data2,&custo);
			}
		}
		else if(entrada=='G'){
			vizualiza(&G);
		}
		else if(entrada=='R'){
			printf("ensira o vertice que deseja remover\n");
			scanf("%d",&data);
			while(data!=-1){
				remove_vertice(&G,data);
				scanf("%d",&data);
			}
		}
		else if(entrada=='O'){
			printf("ensira a aresta, vertice e o custo que deseja ligar-orientado:\n");
			int custo;
			scanf("%d %d %d",&data,&data2,&custo);
			while(data!=-1){
				insere_aresta(&G,data,data2,custo);
				scanf("%d %d %d",&data,&data2,&custo);
			}
		}
		else if(entrada=='r'){
			printf("ensira aresta e o vertice que deseja remover\n");
			scanf(" %d %d",&data,&data2);
			while(data!=-1){
				remove_aresta(&G,data,data2);
				remove_aresta(&G,data2,data);
				scanf(" %d %d",&data,&data2);
			}
		}
		else if(entrada=='l'){
			int distancia[buscamaior(&G)], pai[buscamaior(&G)];
			printf("ensira o vertice que deseja fazer busca\n");
			scanf(" %d",&data);
			while(data!=-1){
				if(pertence(&G,data)==1){
					buscalargura(&G,data,distancia,pai);
					no *q;
					q=G.inicio;
					while(q!=NULL){
						printf("%d dista %d do vertice %d\n",q->vertice,distancia[q->vertice],data);
						q=q->prox;
					}
				}
				scanf(" %d",&data);
			}
		}
		else if(entrada=='p'){
			int distancia[buscamaior(&G)], pai[buscamaior(&G)], f[buscamaior(&G)], data;
			no *q;
			while(data!=-1){
				q=G.inicio;
				buscaemprofundidade(&G,distancia,f,pai);
				while(q!=NULL){
					printf("%d dista %d com tempo %d\n",q->vertice,distancia[q->vertice],f[q->vertice] );
					q=q->prox;
				}
				scanf("%d",&data);
			}
			free(q);
		}
		else if(entrada=='g'){
			scanf("%d",&data);
			while(data!=-1){
				printf("o grau eh de %d\n",grauVertice(&G,data));
				scanf("%d",&data);
			}
		}
		else if(entrada=='c'){
			verificaConexo(&G);
		}
		else if(entrada=='m'){
			no *q;
			q=G.inicio;
			int maior=0, i, j;
			while(q!=NULL){
				if(q->vertice>maior){
					maior=q->vertice;
				}
				q=q->prox;
			}
			//gera a matriz
			int matriz[maior+1][maior+1];
			//inicializa a matriz
			for(i=0;i<maior+1;i++){
				for(j=0;j<maior+1;j++){
					matriz[i][j]=0;
				}
			}
			q=G.inicio;
			while(q!=NULL){
				matriz[q->vertice][0]=q->vertice;
				matriz[0][q->vertice]=q->vertice;
				q=q->prox;
			}
			// transforma o grafo em uma matriz
			aresta *p;
			i=0;
			j=0;
			q=G.inicio;
			while(q!=NULL){
				p=q->prox_aresta;
				while(p!=NULL){
					matriz[q->vertice][p->arestas]=p->custo;
					p=p->prox_aresta;
				}
				q=q->prox;
			}
			for(i=0;i<maior+1;i++){
				for(j=0;j<maior+1;j++){
					printf("|%d| ", matriz[i][j] );
				}
				printf("\n");
			}
		}
		//prim
		else if(entrada=='i'){
			int distancia[buscamaior(&G)], pai[buscamaior(&G)], key[buscamaior(&G)];
			no *q;
			q=G.inicio;
			algoritimo_prim(&G,distancia,pai,key);
			while(q!=NULL){
				printf("%d --- %d\n",pai[q->vertice],key[q->vertice] );
				q=q->prox;
			}
			

		}
		//djikistra
		else if(entrada =='d'){
			int distancia[buscamaior(&G)], pai[buscamaior(&G)];
			no *q;
			q=G.inicio;
			dijkstra(&G,q->vertice,distancia,pai);
			while(q!=NULL){
				printf("%d ---- %d\n",distancia[q->vertice],pai[q->vertice] );
				q=q->prox;
			}
		}
		printf("---------------------------------------------------------------------------\n");
		//scanf(" %c",&entrada);
	}

	return 0;
}
Beispiel #12
0
/* ---------------- Funcao faz (Bronco Dilatacao) --------------- */
void Provas(int prova)
/* ------------------------------------------------------------- */
{
int pontos[6];
char *escalax[6]={"A","B","C","D","E","F"};
char *escalay[5]={"05","07","09","12","15"};
int  i = 0, base=0, j    = 0,Percentual=0;
union	scan  {	int	c;  char   ch[2]; } sc;
int PROVA=FALSE,FIM=FALSE,aux=0,variacao=0;
char _i[5];

   /* ---- Pega VEF base ---- */
   	AmbienteFluxVol ();
	FVpreBD();
	base = VEF1UN;

 if (prova==3)
 {    gprintf (12,12,"Qual a droga (H)istamina ou (M)eticolina ?");
    do{
     LEITURA('c',200,30,_i,1,0,0);
    }while(!pertence(*_i,"HhMm\27"));
    if (*_i==ESC) return;
}

  /* --- inicializa Paciente ---- */
     for(i=0;i<5;i++) pontos[i]=0;
  pontos[0]=base; j=1;
do{
 if(prova==1){
  AmbienteEsforco();   outtextxy(310,2,"PROVA DE BRONCO DILATACAO");
 DesenhaEixos(30,345,10,170,0,54,62,18);
 *escalax=NULL;
 *escalay=NULL;
 outtextxy(87,120,escalax[0]); outtextxy(149,120,escalax[1]);outtextxy(211,120,escalax[2]);
 outtextxy(273,120,escalax[3]);outtextxy(335,120,escalax[4]);outtextxy(300,100,"Tempos");
 outtextxy(12,97,escalay[0]);  outtextxy(12,78,escalay[1]);  outtextxy(12,59,escalay[2]);
 outtextxy(12,40,escalay[3]);  outtextxy(12,21,escalay[4]);  outtextxy(35,8,"Percentual");
  moveto(87,58);
  for(i=1;i<5;i++)
   line(25+62*(i-1),abs( 112-35*(pontos[i-1])/2),
	25+62*(i)  ,abs(112-35*(pontos[i])/2));
}
 else if(prova==2){
	 AmbienteEsforco();   outtextxy(310,2,"ESFORCO");
          DesenhaEixos(30,345,10,370,0,314,62,18);
           outtextxy(87,60,"05"); outtextxy(149,60,"10");outtextxy(211,60,"20");
   outtextxy(273,60,"30");outtextxy(335,60,"45");
   outtextxy(300,40,"Tempos");
   outtextxy(8,74,"125");
   outtextxy(8,89,"250");
   outtextxy(8,104,"05");
   outtextxy(8,119,"1000");
   outtextxy(8,134,"2000");
   outtextxy(35,8,"Percentual");
    moveto(87,58);
    for(i=1;i<5;i++)
     line(25+62*(i-1),abs( 112-35*(pontos[i-1])/2),
	  25+62*(i)  ,abs(112-35*(pontos[i])/2));
 }
 else{
	 AmbienteEsforco();   outtextxy(310,2,"PROVA DE BRONCO RESTRICAO");
      DesenhaEixos(30,345,10,370,0,314,62,18);
   outtextxy(87,60,"05"); outtextxy(149,60,"10");outtextxy(211,60,"20");
   outtextxy(273,60,"30");outtextxy(335,60,"45");
   outtextxy(300,40,"Tempos");
   outtextxy(8,74,"125");
   outtextxy(8,89,"250");
   outtextxy(8,104,"05");
   outtextxy(8,119,"1000");
   outtextxy(8,134,"2000");
   outtextxy(35,8,"Percentual");
    moveto(87,58);
    for(i=1;i<5;i++)
     line(25+62*(i-1),abs( 112-35*(pontos[i-1])/2),
	  25+62*(i)  ,abs(112-35*(pontos[i])/2));
 }
    /* --------- Espera Escolha do usuario ------------- */
     LimpaBufferTeclado();
      sc.c = LeTeclado();
       if (sc.ch[0]==ESC) return;
      if (sc.ch[0]==13) PROVA=TRUE;
     if (sc.ch[0] == 0) if((sc.ch[1])==59){
      if(prova==1){ chama_help("02"); chama_help("12");PROVA=FALSE;
      } else if(prova==2){chama_help("01"); PROVA=FALSE;}
	     else {chama_help("03"); PROVA=FALSE;}
     }

/* ------ Executa a prova para pontos --------- */
   if (PROVA==TRUE){
    AmbienteFluxVol ();
     FVposBD();
      pontos[j] = 100*VEF1UN/base; /* valor percentual a ser plotado */
       j++;
   }
   for(i=1;i<5;i++) {
    aux = (aux<pontos[i])?pontos[i]:aux;
    variacao = abs(base - aux)*100;
   }
  if(prova==1){
   gprintf(400,170,"Aumento do volume(ml) na prova:");
   itoa(variacao,_i,10);
    gprintf(576,170,_i);
  }
  if(prova==3){
   gprintf(400,170,"PD20: ");
   ultoa((float) log10(pow(2.0, (double) (Percentual))),_i,10);
    gprintf(576,170,_i);
  }
 }while (!FIM);
} /* fim  */
Beispiel #13
0
void main ( int argc , char **argv )
{
#define QTD_MPRINC 8
#define QTD_MSECUN 4
   char *opcao1[8] = { "Configuracao","Calibrar Sistema","Dados do Paciente",
		               "Ventilacao Voluntaria Maxima","Espirometria Forcada",
		               "Capacidade Vital Lenta","Resultados","Terminar" };
   char *opcao2[4] = { "Visualizar","Imprimir","Arquivo","Retornar"};


	int	exit = FALSE;
	extern int GlobOffSetP;

	if (argc > 1 && strcmp ( strupr ( argv[1] ) , "-V1" ) == 0)
/* sem correcao de BTPS */
		Versao = 1, --argc, ++argv;

	else if (argc > 1 && strcmp ( strupr ( argv[1] ) , "-V2" ) == 0)
/* com correcao para ar expirado */
		Versao = 2, --argc, ++argv;

	else if (argc > 1 && strcmp ( strupr ( argv[1] ) , "-V3" ) == 0)
/* com correcao para ar ambiente a 37 graus */
		Versao = 3, --argc, ++argv;

	else /* Nao escolheu nenhuma versao, assume -V2 */
		Versao = 2;

	if (argc > 1)
		GlobOffSetP = atoi(argv[1]);
	else
		GlobOffSetP = 4;

/*	printf( "Usando OffsetP==%d\n", GlobOffSetP );
	getchar();                                               */

#if defined(ENT_ARQ) || defined(ENT_ARQ_R)
	strcpy ( NomeCurva , argv[1] );
#endif

	_control87 ( MCW_EM  ,  MCW_EM );

#ifdef LINX
   vetor = getvect(0x1c);
   setvect(0x1c,TrataInterrup); /* seta a Interrupcao 11 do vetor para a funcao a*/
#endif

#ifdef PLACA12
	setvect ( 10  ,  TrataInterrup );
#else
	setvect ( 11  ,  TrataInterrup );
#endif
	LeCoef ();             /* le coeficientes */

/*	*ApontEspirometria = NULL;
	*ApontVVM = NULL;
	*ApontFluxPreBD = NULL;
	*ApontFluxPosBD = NULL;
*/
	RegistroTimer();
	LeData ();
	ModoGrafico ();
   Chama_Padrao();  /* pega valores default de cor,laudo,pereira,impressora */
	do{
		if (limpar) LimpaTela ();
		LimpaBufferTeclado ();
		InitialScreen();
		switch (menu(MENUPRINCIPAL,QTD_MPRINC,opcao1)) {
		  case 0 : Padrao();
			 limpar=TRUE;
			 break;

			case 1 : if(GanhoOk) LiberaAreas();
				  Calibragem ();
				 if(GanhoOk) ReservaAreas ();
				limpar = TRUE;
				break;
			case 2 :if(GanhoOk){
				DadosPaciente ();
				limpar = TRUE; }
				break;
			case 3 :
				if (GanhoOk && DadosPacienteOk)
					{
					VentVol ();
					limpar = TRUE;
					}
				else
					limpar = FALSE;
				break;
			case 4 :
#if !defined(ENT_ARQ) && !defined(ENT_ARQ_R)
				if ((GanhoOk && DadosPacienteOk) || (Versao == 3))
					{
#endif
					FluxVol ();
#if !defined(ENT_ARQ) && !defined(ENT_ARQ_R)
					limpar = TRUE;
					}
				else
					limpar = FALSE;
#endif
				break;
			case 5 :
			  if (GanhoOk && DadosPacienteOk)
			   {
                            setviewport ( 0 , 0 , 719 , 347 , 1 );
			    gprintf(585,280,"Ar Residual ? (S/N)");
			    do{
			       LEITURA('c',683,280,Resp,1,0,0);
			    }while(!pertence(*Resp,"SsNn"));
			    if(pertence(*Resp,"Ss")) {
			      VAR_RESP=TRUE;
			      Volume_de_ar_residual();
			    }
			    else  VAR_RESP=FALSE;
			    Espirometria ();
			    limpar = TRUE;
			    }
			    else
			    limpar = FALSE;
			    break;
			case 6 :if ((DadosPacienteOk || OK) && GanhoOk){
				switch(menu(MENUSECUNDARIO,QTD_MSECUN,opcao2)){
				 case SALVAR: Arquivar();
					      break;

				 case IMPRIMIR:	if (DadosPacienteOk)
					Impressao(1);
					break;

				 case VISUALIZAR:if (DadosPacienteOk)
					Impressao(0);
					break;

				 case 27:
				 case  3: break;
				/* case 9: chama_help(002);  break;*/
				}
				limpar=TRUE;
			}
				else limpar=FALSE;
				break;

		/*case 9: chama_help(002);  break;*/
			case 7:
				exit = TRUE;
			break;
			}
		}
	while (!exit);
	closegraph ();
	LiberaAreas ();
	}