示例#1
0
文件: render-png.c 项目: lyuxiao/misc
int main(int argc, char *argv[]) {
  char *prog = argv[0];
  int opt, rc=-1;
  hex_t h;

  utarray_new(cfg.hexv, &hex_icd);

  while ( (opt = getopt(argc, argv, "v+i:o:h")) != -1) {
    switch (opt) {
      case 'v': cfg.verbose++; break;
      case 'i': cfg.infile = strdup(optarg); break;
      case 'o': cfg.outfile = strdup(optarg); break;
      case 'h': default: usage(prog); break;
    }
  }

  if (!cfg.outfile || !cfg.infile) usage(prog);

  /* read input file */
  tpl_node *tn = tpl_map("A(sii)", &h.id, &h.x, &h.y);
  if (tpl_load(tn, TPL_FILE, cfg.infile)) goto done;
  while(tpl_unpack(tn,1) > 0) utarray_push_back(cfg.hexv, &h);
  tpl_free(tn);

  find_bounds();
  draw_image();
  rc = 0;

 done:
  utarray_free(cfg.hexv);
  return rc;

}
示例#2
0
void findFrequency()
{
	/*
	@Statement - Given a sorted array, find the number of occurances of a number in less than O(n)
	*/
	int array[7] = {1,1,2,3,3,4,5};
	int val = 4;

	find_bounds(array,7,val);// use binary search --O(logn)
}