Beispiel #1
0
int main(int argc, char* argv[]){
  
  char *ip1 = "128.140.80.0";
  char *ip2 = "128.140.127.255";

  in_addr_t a1 = htonl(inet_addr(ip1));
  in_addr_t a2 = htonl(inet_addr(ip2));

  printf("ip1: %u\n", a1);
  printf("ip2: %u\n", a2);
  printf("ip2 - ip1: %u\n", (a2 -a1));


  int a = 10;
  if(a)
    printf("that is right\n");

  if( 10 < 332 < 199)
    printf("%d\n", 2*4);


  /*  printf("%d\n", sizeof(suseconds_t));
  suseconds_t k = 0xffffffff;
  printf("%u\n", k);
  */
  struct timespec curr;

  clock_gettime(CLOCK_REALTIME, &curr);

  struct timespec timestamp;

  
  memcpy(&timestamp, &curr, sizeof(struct timespec));

  printf("%d\n", timestamp);

  clock_gettime(CLOCK_REALTIME, &curr);

  printf("%u: %u\n", testa(timestamp).tv_sec, timestamp.tv_sec);


  if(121)
    printf("YES\n");


  char temp1[100];
  char temp2[100];
  temp2[10] = 'h';
  temp2[11] = 'd';

  memcpy(temp1, &temp2[10], 2);
  printf("%s\n", temp1);


  long k = 10;
  double v = (double)k;

  printf("%f\n", v);
}
Beispiel #2
0
int main()
 {
    clock_t t1 = clock();
     for (int i=0;i<8;i++)
         testa();
     clock_t t2 = clock();
     std::cout<<" "<<t2-t1<<std::endl;
    clock_t t3 = clock();
     for (int i=0;i<8;i++)
         testb();
     clock_t t4 = clock();
     std::cout<<" "<<t4-t3<<std::endl;
     return 0;
 }
Beispiel #3
0
int
arraytest(int nargs, char **args)
{
	struct array *a;

	(void)nargs;
	(void)args;

	kprintf("Beginning array test...\n");
	a = array_create();
	KASSERT(a != NULL);

	testa(a);

	array_setsize(a, 0);

	testa(a);

	array_setsize(a, 0);
	array_destroy(a);

	kprintf("Array test complete\n");
	return 0;
}
Beispiel #4
0
int main()
{
  int i;

  FILE *fin = fopen("hamming.in", "r");
  FILE *fout = fopen("hamming.out", "w");
  /*
  FILE *fin = stdin;
  FILE *fout = stdout;
  */

  fscanf(fin, " %d %d %d", &n, &b, &d);

  memset(num, 0, n*sizeof(int));
  memset(usado, 0, 256*sizeof(char));
  usado[0] = 1;

  i = 1;
  while(i < n){
    if(!(usado[num[i]]) && testa(num[i], i)){
      usado[num[i]] = 1;
      i++;
    }
    else
      num[i]++;
  }

  qsort(num, n, sizeof(int), compara);

  for(i=0; i<n; i++){
    if(i % 10 == 0 && i != 0)
      fprintf(fout, "\n");
    if(i % 10 == 0)
      fprintf(fout, "%d", num[i]);
    else
      fprintf(fout, " %d", num[i]);
  }
  fprintf(fout, "\n");
  /*printf("\n\n%d\n", dist(7, 8));*/
  return 0;
}
Beispiel #5
0
char delet(char *str, struct trie *ptr){
	struct trie *t;
	int tam;
	int i;
	int local;
	tam=strlen(str);
	t=ptr;
	for(i=0;i<tam;i++){
		local=str[i]-'a';
		t=t->filho[local];
		if(!t){
			return 'f';
		}
		
		
	}
	if(!t->filho[26]){
		return 'f';
	}
	//t->filho[26]=NULL;
	t=testa(tam,t);
	return 'v';
}