Example #1
0
int espelho(TArvoreA* RaizA,TArvoreB* RaizB){
  if(RaizA==NULL || RaizB==NULL)
      return 0;
  else if(RaizA->valor==RaizB->valor){
      espelho(RaizA->esq,RaizB->esq);
      espelho(RaizA->dir,RaizB->dir);
      return 1;
 }
  else
      return 0;
 }
Example #2
0
int main(){
    int x=0,y=0;
    TArvoreA *RaizA =NULL;
		TArvoreB *RaizB =NULL;
    while(1){
			printf("Informe o numero: ");
			scanf(" %d",&x);
			if(x == -999)
				break;
      inserirA(&RaizA,x);
    };
		while(1){
			printf("Informe o numero: ");
			scanf(" %d",&y);
			if(y == -999)
				break;
			inserirB(&RaizB,y);
		};

    if(RaizA==NULL && RaizB==NULL)
      printf("\nAmbas arvores estão vazias\n");
    x=espelho(RaizA,RaizB);
    if(x==1 && (contaNoA(RaizA)==contaNoB(RaizB)))
      printf("\nAs arvores são completamente iguais\n");
    else
        printf("\nAs arvores não são iguais\n");

    printf("\nArvore em ordem:\n");
    ImprimeArvoreA(RaizA);
    printf("\n\n");
		ImprimeArvoreB(RaizB);
		printf("\n\n");
    return 0;
}
Example #3
0
int main(int argc, char *argv[]){     /* funcao principal que recebe uma letra 'n', 'e' ou 'p' de maneira a escolher a funcao que define o novo formato da imagem */

	switch(argv[1][0]) {
		case 'n':{
			cabecalho("# negativo", 1, 1);
			negativo();
			break;
		}
		case 'e': {
			cabecalho("# espelho", 1, 1);
			espelho();
			break;
		}
		case 'p': {
			cabecalho("# padrao", atoi(argv[2]), atoi(argv[3])); 
			padrao(atoi(argv[2]), atoi(argv[3]));
		break; 
		} 
	default:
		return EXIT_FAILURE; /* Opção desconhecida (STDLIB)*/ 
	}
	return EXIT_SUCCESS; /* Termina o programa com sucesso (STDLIB) */
}