Ejemplo n.º 1
0
int main(int argc, char **argv) {

// inicialização
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA);
	glutInitWindowPosition(300,100);
	glutInitWindowSize(800,600);
	glutCreateWindow("Bar@DI-UM");
		

// registo de funções 
	glutDisplayFunc(renderScene);
	glutIdleFunc(renderScene);
	glutReshapeFunc(changeSize);

// pôr aqui registo da funções do teclado e rato
	glutSpecialFunc(keyboard);
	glutMotionFunc(mouse);
	glutMouseFunc(rato);
// pôr aqui a criação do menu
	criarMenu();
	converte();
// alguns settings para OpenGL
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);

//init
	converte();

// entrar no ciclo do GLUT 
	glutMainLoop();
	
	return 1;
}
Ejemplo n.º 2
0
char obj_figura::exibe()
{
  if (!carquivo_definido)
    return FALSO;
  else
   {
     if (!cbuffer_definido)
     {
       cbuffer = (estrutura_circular*) malloc(sizeof(estrutura_circular) * cnumero_de_nos);
       cbuffer_definido = VERDADEIRO;

       rewind(carquivo);
       fread(cbuffer, sizeof(estrutura_circular), cnumero_de_nos, carquivo);
     }

     if (cgrossura == 3)
       setlinestyle(SOLID_LINE, 1, 3);
     else
       setlinestyle(SOLID_LINE, 1, 1);

     for (unsigned int cont = 0; cont < cnumero_de_nos; cont++)
     {
       tipo_xy x1, y1, x2, y2;
       converte(cbuffer[cont].angulo1 + cangulo, cbuffer[cont].raio1 * craio, &x1, &y1, cx, cy);
       converte(cbuffer[cont].angulo2 + cangulo, cbuffer[cont].raio2 * craio, &x2, &y2, cx, cy);
       cor(cbuffer[cont].cor);
       line(x1, y1, x2, y2);
     }

     return VERDADEIRO;
   }
}
Ejemplo n.º 3
0
char obj_figura::apaga(const tipo_cor& vcor)
{
  if (!carquivo_definido)
    return FALSO;
  else
   {
     if (!cbuffer_definido)
     {
       cbuffer = (estrutura_circular*) malloc(sizeof(estrutura_circular) * cnumero_de_nos);
       cbuffer_definido = VERDADEIRO;
       rewind(carquivo);
       fread(cbuffer, sizeof(estrutura_circular), cnumero_de_nos, carquivo);
     }

     for (unsigned int cont = 0; cont < cnumero_de_nos; cont++)
     {
       tipo_xy x1, y1, x2, y2;
       converte(cbuffer[cont].angulo1 + cangulo, cbuffer[cont].raio1 * craio, &x1, &y1, cx, cy);
       converte(cbuffer[cont].angulo2 + cangulo, cbuffer[cont].raio2 * craio, &x2, &y2, cx, cy);
       cor(vcor);
       line(x1, y1, x2, y2);
     }

     return VERDADEIRO;
   }
}
Ejemplo n.º 4
0
int main(int argc, char* argv[]) {
  FILE* fin = fopen("ride.in", "r");
  FILE* fout = fopen("ride.out", "w");
  char group[7], comet[7];
  fscanf(fin, "%s", group);
  fscanf(fin, "%s", comet);
  if (converte(group) == converte(comet)) {
    fprintf(fout, "GO\n");
  } else {
    fprintf(fout, "STAY\n");
  }
  return 0;
}
Ejemplo n.º 5
0
Archivo: graph.c Proyecto: Surtr04/misc
int main () {


	Grafo1 *g = (Grafo1*) malloc (sizeof(Grafo1)); 
	g->arestas[0] = 1;
	g->arestas[1] = 2;
	g->arestas[2] = 2;
	g->arestas[3] = 4;
	g->arestas[4] = 4;
	g->arestas[5] = 1;
	g->arestas[6] = 2;
	g->arestas[7] = 5;
	g->arestas[8] = 3;
	g->vertices[0] = 0;
	g->vertices[1] = 2;
	g->vertices[2] = 4;
	g->vertices[3] = 5;
	g->vertices[4] = 7;
	g->vertices[5] = 8;
	g->vertices[6] = 9;
	Grafo2 h;
	
	converte (g,h);
	prtAdjencyList(h);
	
}
Ejemplo n.º 6
0
void gt_md5_encoder_finish(GtMD5Encoder *enc, unsigned char *output,
                           char *outstr)
{
  gt_assert(enc && output);
  if (enc->status != 2) {
    if (enc->len > 0) {
      digest(enc->wbuff, enc->d);
      enc->d[0]+=enc->d_old[0]; enc->d[1]+=enc->d_old[1];
      enc->d[2]+=enc->d_old[2]; enc->d[3]+=enc->d_old[3];
    }
    enc->d_old[0]=enc->d[0]; enc->d_old[1]=enc->d[1];
    enc->d_old[2]=enc->d[2]; enc->d_old[3]=enc->d[3];
    enc->status = converte(enc->wbuff, NULL, 0, enc->status);
    gt_assert(enc->status == 2);
  }
  put_length(enc->wbuff, enc->len);
  digest(enc->wbuff, enc->d);
  enc->d[0]+=enc->d_old[0]; enc->d[1]+=enc->d_old[1];
  enc->d[2]+=enc->d_old[2]; enc->d[3]+=enc->d_old[3];
  word32tobytes(enc->d, (char*) output);
  if (outstr) {
    snprintf(outstr, 33,
             "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
             output[0], output[1], output[2], output[3], output[4], output[5],
             output[6], output[7], output[8], output[9], output[10], output[11],
             output[12], output[13], output[14], output[15]);
  }
}
Ejemplo n.º 7
0
int main()
{
    float c, result;
    printf("entre com a temperatura em celsius: " );
    scanf("%f", &c);
    
    result = converte(c);
    printf("%.2f celsius = %.2f farenheit", c,result);
}
Ejemplo n.º 8
0
// EDITOR -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
inline void obj_figura::poe(const tipo_xy& x1, const tipo_xy& y1,
                            const tipo_xy& x2, const tipo_xy& y2,
                            const tipo_cor& vcor)
{
  estrutura_circular caux;

  converte(x1, y1, &caux.angulo1, &caux.raio1);
  converte(x2, y2, &caux.angulo2, &caux.raio2);

  caux.angulo1 = -caux.angulo1;
  caux.angulo2 = -caux.angulo2;
  caux.cor = vcor;
  cor(vcor);
  line(x1, y1, x2, y2);

  fwrite(&caux, sizeof(estrutura_circular), 1, carquivo);

  cnumero_de_nos++;
}
Ejemplo n.º 9
0
int main(int argc, char * argv[]) { 
	FILE * arq_divisores; 
	if (!check_parameters(argc, argv)){ 
		usage(); 
		return 1; 
	} 
	arq_divisores = fopen(argv[2],"w"); 
	if (arq_divisores== NULL){ 
		printf("ERROR: Não foi possível abrir o arquivo %s.\n",argv[2]); 
		return 2; 
	} 
	if (gera_divisores(converte(argv[1]),arq_divisores) != 0){ 
		printf("ERROR: Problemas ao escrever dados no arquivo %s.\n", argv[2]); 
		return 3; 
	} 
	gera_divisores(converte(argv[1]), arq_divisores);
	fclose(arq_divisores); 
	return 0; 
}
Ejemplo n.º 10
0
int main()
{
	char strx[10], stry[10], strz[10];
	int x, y, z;
	while(scanf("%s %s %s", strx, stry, strz))
	{
		x = converte(strx);
		y = converte(stry);
		z = converte(strz);
		if(x == 0 || y == 0 || z == 0) break;
		scanf("%d%d%d", &p, &m, &g);
		up = um = ug = 0;
		if(!arruma(x, y)) printf("impossivel\n");
		else if(!arruma(x, z)) printf("impossivel\n");
		else if(!arruma(x, z)) printf("impossivel\n");
		else if(!arruma(y, z)) printf("impossivel\n");
		else if(!arruma(y, z)) printf("impossivel\n");
		else printf("%d %d %d\n", up, um, ug);
	}
	return 0;
}
Ejemplo n.º 11
0
int main(int argc, char** argv) {
    PTno listaNome = carregaDados();
    PTno listaProj = converte(listaNome);
    char nome[10];
    mostraPorNome(listaNome);
    mostraPorProj(listaProj);
    printf("Projeto mais longo = %d\n", projMaisTempo(listaProj));
    nomeMaisTempo(listaNome, nome);
    printf("Nome com mais tempo alocado = %s\n", nome);
    printf("Tempo Total dos projetos = %d\n", tempoTotal(listaNome));
    mostraPercAlocado(listaNome);
    return (EXIT_SUCCESS);
}
Ejemplo n.º 12
0
void gt_md5_encoder_add_block(GtMD5Encoder *enc, const char *message,
                              GtUword len)
{
  gt_assert(enc && message && len < 65);
  if (enc->len > 0) {
    digest(enc->wbuff, enc->d);
    enc->d[0]+=enc->d_old[0]; enc->d[1]+=enc->d_old[1];
    enc->d[2]+=enc->d_old[2]; enc->d[3]+=enc->d_old[3];
  }
  enc->d_old[0]=enc->d[0]; enc->d_old[1]=enc->d[1];
  enc->d_old[2]=enc->d[2]; enc->d_old[3]=enc->d[3];
  enc->status = converte(enc->wbuff, message, len, enc->status);
  enc->len += len;
}
Ejemplo n.º 13
0
void mouse(int x, int y){
	float diff_x = x - 400;
	float diff_y = y - 300;
	
	alfa = -speed*(diff_x/400);

	beta = speed*(diff_y/300);
	if (beta > 1.5f)
		beta = 1.5f;
	if (beta < -1.5f)
		beta = -1.5f;
	converte();
	glutPostRedisplay();
}
Ejemplo n.º 14
0
char obj_figura::exibe()
{
  if (!carquivo_definido)
    return FALSO;
  else
   {
     if (ctela.pagina_atual == 0)
       setactivepage(1);
     else
       setactivepage(0);

     if (!cbuffer_definido)
     {
       cbuffer = (estrutura_circular*) malloc(sizeof(estrutura_circular) * cnumero_de_nos);
       cbuffer_definido = VERDADEIRO;

       rewind(carquivo);
       fread(cbuffer, sizeof(estrutura_circular), cnumero_de_nos, carquivo);
     }

     for (unsigned int cont = 0; cont < cnumero_de_nos; cont++)
     {
       tipo_xy x1, y1, x2, y2;
       converte(cbuffer[cont].angulo1 + cangulo, cbuffer[cont].raio1 * craio, &x1, &y1, cx, cy);
       converte(cbuffer[cont].angulo2 + cangulo, cbuffer[cont].raio2 * craio, &x2, &y2, cx, cy);
       cor(cbuffer[cont].cor);
       line(x1, y1, x2, y2);
     }

     if (ctela.pagina_atual == 0)
       setactivepage(0);
     else
       setactivepage(1);

     return VERDADEIRO;
   }
}
Ejemplo n.º 15
0
static void md5_close (const char *message, size_t len, WORD32 d[4], size_t total) {
  int status = 0;
  long i = 0;
  while (status != 2) {
    WORD32 d_old[4];
    WORD32 wbuff[16];
    int numbytes = (len-i >= 64) ? 64 : len-i;
    /*salva os valores do vetor digest*/
    d_old[0]=d[0]; d_old[1]=d[1]; d_old[2]=d[2]; d_old[3]=d[3];
    status = converte(wbuff, message+i, numbytes, status);
    if (status == 2) put_length(wbuff, total);
    digest(wbuff, d);
    d[0]+=d_old[0]; d[1]+=d_old[1]; d[2]+=d_old[2]; d[3]+=d_old[3];
    i += numbytes;
  }
}
Ejemplo n.º 16
0
Archivo: md5.c Proyecto: Safe3/KendyNet
void md5 (const char *message, long len, char *output) {
  WORD32 d[4];
  int status = 0;
  long i = 0;
  inic_digest(d);
  while (status != 2) {
    WORD32 d_old[4];
    WORD32 wbuff[16];
    int numbytes = (len-i >= 64) ? 64 : len-i;
    /*salva os valores do vetor digest*/
    d_old[0]=d[0]; d_old[1]=d[1]; d_old[2]=d[2]; d_old[3]=d[3];
    status = converte(wbuff, message+i, numbytes, status);
    if (status == 2) put_length(wbuff, len);
    digest(wbuff, d);
    d[0]+=d_old[0]; d[1]+=d_old[1]; d[2]+=d_old[2]; d[3]+=d_old[3];
    i += numbytes;
  }
  word32tobytes(d, output);
}
Ejemplo n.º 17
0
char obj_figura::edita()
{
  ctela.limpa_teclado();

  if (carquivo_somente_leitura)
    return FALSO;
  else
    if (!carquivo_definido)
      return FALSO;
    else
     {
       tipo_xy cx, cy;
       tipo_xy cxant, cyant;
       tipo_xy ccentrox, ccentroy;
       tipo_angulo cangulo = 0;
       tipo_raio craio = 1;
       char ccirculo = FALSO;
       char ccor = 15;
       char* cursor = (char*) malloc(sizeof(char) * 2);
       char caracter = NULL;
       char clicado = FALSO;
       char velocidade = 1;

       cx = (tipo_xy) (ctela.max_x + 1) / 2;
       cy = (tipo_xy) (ctela.max_y + 1) / 2;

       ccentrox = cx;
       ccentroy = cy;

       cor(8);
       line(cx, 0, cx, ctela.max_y);
       line(0, cy, ctela.max_x, cy);

       putpixel(0, 0, 15);
       getimage(0, 0, 0, 0, cursor);
       putpixel(0, 0, 0);

       do
       {
         if (keypressed)
         {
           ctela.le_teclado(&caracter);

           switch (caracter)
           {
             case CARACTER_NULO:
               ctela.le_teclado(&caracter);

               if (!ccirculo)
               {
                 switch (caracter)
                 {
                   case SETA_CIMA:
                     cy -= velocidade;
                   break;

                   case SETA_BAIXO:
                     cy += velocidade;
                   break;

                   case SETA_DIREITA:
                     cx += velocidade;
                   break;

                   case SETA_ESQUERDA:
                     cx -= velocidade;
                   break;
                 }
               }
               else
                 {
                   switch (caracter)
                   {
                     case SETA_CIMA:
                       craio += velocidade;
                     break;

                     case SETA_BAIXO:
                       craio -= velocidade;
                     break;

                     case SETA_DIREITA:
                       cangulo += velocidade;
                     break;

                     case SETA_ESQUERDA:
                       cangulo -= velocidade;
                     break;
                   }

                   converte(cangulo, craio, &cx, &cy, ccentrox, ccentroy);
                 }

             break;

             case BARRA_DE_ESPACO:
               if (!clicado)
               {
                 clicado = VERDADEIRO;
                 cxant = cx;
                 cyant = cy;
               }
               else
                 {
                   clicado = FALSO;
                   poe(cx, cy, cxant, cyant, ccor);
                 }
             break;

             case CTRL_A:
               poe(cx + 5, cy, cx + 20, cy + 13, ccor);
               poe(cx, cy, cx + 15, cy + 16, ccor);
               poe(cx - 2, cy + 5, cx + 13, cy + 19, ccor);
               poe(cx - 4, cy + 7, cx + 11, cy + 20, ccor);
               poe(cx - 5, cy + 14, cx + 12, cy, ccor);
               poe(cx - 1, cy + 16, cx + 15, cy + 2, ccor);
               poe(cx + 3, cy + 19, cx + 17, cy + 5, ccor);
               poe(cx + 6, cy + 20, cx + 20, cy + 8, ccor);
             break;

             case CTRL_B:
               ccor++;

               if (ccor > 15)
                 ccor = 0;
             break;

             case CTRL_D:
               if (!ccirculo)
               {
                 ccentrox = cx;
                 ccentroy = cy;
               }
               else
                 if (ccirculo)
                 {
                   cx = ccentrox;
                   cy = ccentroy;
                 }

               ccirculo = !ccirculo;
             break;

             case MAIS:
               velocidade++;
             break;

             case MENOS:
               velocidade--;
             break;

             case CTRL_Z:
               tira();
             break;
           }
         }

         putimage(cx, cy, cursor, XOR_PUT);
         delay(1);
         putimage(cx, cy, cursor, XOR_PUT);
       }
       while(caracter != ENTER);

       return VERDADEIRO;
     }
}
Ejemplo n.º 18
0
Archivo: run.c Proyecto: magden/project
/* Second run*/
int run2(input_line * input, int linenum, char *input_fileName)
{
	char addr_array[NUM_OF_DIGITS+1], instr_array[NUM_OF_DIGITS+2], fileName[FILE_NAME_SIZE];/*TEMP ARRAYS FOR CODE SAVING*/
	int  x, line_count = 0;
	FILE *ob, *ext, *ent;
	/*Files opening*/
	sprintf(fileName, "%s.ob", input_fileName);
	ob = fopen(fileName, "w");
	if (ob == NULL)
	{
		printf("Error! Can't create %s file.\n", fileName);
		return 0;
	}
	sprintf(fileName, "%s.ext", input_fileName);
	ext = fopen(fileName, "w");
	if (ext == NULL)
	{
		printf("Error! Can't create %s file.\n", fileName);
		return 0;
	}
	sprintf(fileName, "%s.ent", input_fileName);
	ent = fopen(fileName, "w");
	if (ent == NULL)
	{
		printf("Error! Can't create %s file.\n", fileName);
		return 0;
	}
	/*Prints how many instructions and data.*/
	fprintf(ob, "\t%s   %s\n", base_to_base_con((IC - START - DC), BASE, addr_array, 0), base_to_base_con(DC, BASE, instr_array, NO_LZ));
	/*line_count++;*/
	for (i = 0; i < linenum; i++)
	{
		if (!input[i].line_compl)
		{
			address_checker(input[i].instruction, input[i].line_number);

			/*Check if a command like MOV1 or MOV2, add1 or add2 etc... */
			x = input[i].how_many;
			while (x != 0)
			{
				/* The first line of of instruction(not operands).*/
				fprintf(ob, "%s\t%s\t\n", base_to_base_con(line_count + LINE_OFFSET, BASE, addr_array, NO_LZ), base_to_base_con(converte(*(input[i].instruction)).data, BASE, instr_array, LZ));
				line_count++;

				/*If two registers are in the instruction. In machine language they must be in ONE line.*/
				if ((input[i].instruction->dest_addr == 3) && (input[i].instruction->src_addr == 3))
				{
					int dest, src;
					int tmp1 = 0;
					int tmp2 = 0;
					int fin;
					int y = MAX_OP_NAME;
					int z = 1;

					if (input[i].src_opr[0] == '$')
					{
						if (check_for_last_oper()){
							while (z != MAX_OP_NAME) /*this loop is converting back the last reg value(in base4) to int*/
							{
								tmp1 += (last_dest_opr[y - z] - '0')*(int)(power(4, z - 1));
								z++;
							}
						}
						else
						{
							ERROR("The $$ can't be used at this line.Because no were operands before this instruction.", input[i].line_number);
							error_flag = TRUE;
						}
					}
					else
					{
						src = (input[i].src_opr[1]) - '0';
						tmp1 = src << 7;
						strcpy(last_dest_opr, base_to_base_con(tmp1, BASE, instr_array, LZ));/*Save this reg for may be next $$*/
					}
					dest = (input[i].dest_opr[1]) - '0';
					tmp2 = dest << 2;
					fin = tmp1 | tmp2;
					fprintf(ob, "%s\t%s\n", base_to_base_con(line_count + LINE_OFFSET, BASE, addr_array, NO_LZ), base_to_base_con(fin, BASE, instr_array, LZ));
					line_count++;
				}
				else
				{
					if (input[i].instruction->gr_code == 2)
					{
						if (input[i].src_opr)
							operand_extractor(input[i].src_opr, input[i].instruction->src_addr, ob, ext, &line_count, input[i].line_number, TRUE);
						if (input[i].dest_opr)/*The last argumet of the funct"TRUE" means that is's source operand(not dest)  */
							operand_extractor(input[i].dest_opr, input[i].instruction->dest_addr, ob, ext, &line_count, input[i].line_number, FALSE);
					}
					if (input[i].instruction->gr_code == 1)
						operand_extractor(input[i].dest_opr, input[i].instruction->dest_addr, ob, ext, &line_count, input[i].line_number, TRUE);

				}
				x--;
			}
		}
	}

	/*Write .ob file*/
	for (i = 0; i < DC; i++)
	{
		fprintf(ob, "%s\t%s\n", base_to_base_con(line_count + LINE_OFFSET, BASE, addr_array, NO_LZ), base_to_base_con(data_array[i].data, BASE, instr_array, LZ));
		line_count++;
	}

	/*Write .ent file*/
	for (i = 0; i<entryCount; i++)
	{

		if ((tmp_node = search_node(array_entry[i], instructions_table)))
			fprintf(ent, "\t%s\t\t%s\n", array_entry[i], base_to_base_con(tmp_node->num, BASE, addr_array, NO_LZ));

		else if ((tmp_node = search_node(array_entry[i], data_table)))
			fprintf(ent, "\t%s\t%s\n", array_entry[i], base_to_base_con(tmp_node->num, BASE, addr_array, NO_LZ));

		else
		{
			fprintf(stderr, "ERROR: Ca't fund address for the entry %s.\n", array_entry[i]);
			error_flag = TRUE;
		}
	}

	/*Close all files*/
	fclose(ob);
	fclose(ext);
	fclose(ent);

	/*Delete all created files in case of failure*/
	if (error_flag)
	{
		sprintf(fileName, "%s.ob", input_fileName);
		remove(fileName);
		sprintf(fileName, "%s.ext", input_fileName);
		remove(fileName);
		sprintf(fileName, "%s.ent", input_fileName);
		remove(fileName);
	}

	/*Tester if no externs provided.*/
	else if (externCount == 0)
	{
		sprintf(fileName, "%s.ext", input_fileName);
		remove(fileName);
	}
	/*Tester if no entrys provided.*/
	else if (entryCount == 0)
	{
		sprintf(fileName, "%s.ent", input_fileName);
		remove(fileName);
	}
	return 0;
}