コード例 #1
0
ファイル: 套题_13.c プロジェクト: hyy044101331/myHangdian
main()
{
  int i;
  readDat();
  jsValue();
  writeDat();
  for (i=0;i<cnt;i++)  printf("b[%d]=%d\n",i,b[i]);
}
コード例 #2
0
ファイル: 套题_13.c プロジェクト: hyy044101331/myHangdian
main()
{
  int i=0;
  readDat();
  jsValue();
  writeDat();
  printf("cnt=%d\n满足条件的平均值pjz1=%7.2lf\n不满足条件的平均值pjz2=%7.2lf\n",
cnt,pjz1,pjz2);
}
コード例 #3
0
ファイル: 206.C プロジェクト: JackDrogon/Study
main()
{
	clrscr();
	puts(" This program is to find the real root of");
	puts("          function cos(x)-x=0.");
	printf(" >> The real root is %f.\n",countvalue());
	printf(" >> The result of cos(%f)-%f is %f.\n",countvalue(),countvalue(),cos(countvalue())-countvalue());
	writeDat();
	PressKeyToQuit();
}
コード例 #4
0
ファイル: 1_pro.c プロジェクト: hyy044101331/myHangdian
void main()
{
  int i ;
  readDat() ;
  jsVal() ;
  printf("满足条件的数=%d\n", cnt) ;
  for(i = 0 ; i < cnt ; i++)  printf("%d ", b[i]) ;
  printf("\n") ;
  writeDat() ;
}
コード例 #5
0
ファイル: apng.cpp プロジェクト: ClarkWang12/object-proposals
void writeAPNG( const std::string & filename, const std::vector<RMatrixXu8> & labels ) {
	eassert( labels.size()>0 );
	int N=labels.size(),W=labels[0].cols(),H=labels[0].rows();
	
	std::ofstream os( filename.c_str(), std::fstream::out | std::fstream::binary );
	char magic[9]="\x89\x50\x4E\x47\x0D\x0A\x1A\x0A";
	os.write( magic, 8 );
	writeHDR( os, W, H );
	writePLTE( os, true );
	writeACTL( os, N );
	for( int i=0, seq_n=0; i<N; i++ ) {
		writeFCTL( os, seq_n++, W, H );
		std::vector<char> data( H*(W+1), 0 );
		RMatrixXu8::Map( reinterpret_cast<uint8_t*>(data.data()), H, W+1 ).rightCols(W) = labels[i];
		if(!i)
			writeDat( os, data );
		else
			writeFDat( os, data, seq_n++ );
	}
	writeChunk( os, "IEND", std::vector<char>() );
}
コード例 #6
0
ファイル: prep_sites.cpp プロジェクト: SamueleSoraggi/angsd
void filt_gen(const char *fname,int posi_off,int doCompl) {
  fprintf(stderr,"\t-> Filterfile: %s supplied will generate binary representations... \n",fname);

  gzFile gz = Z_NULL;
  if((gz = gzopen(fname,"r"))==Z_NULL){
    fprintf(stderr,"Problem opening file:%s\n",fname);
    exit(0);
  }

  char* outnames_bin = append(fname,BIN);
  char* outnames_idx = append(fname,IDX);
  
  BGZF *cfpD = bgzf_open(outnames_bin,GZOPT);
  FILE *fp=fopen(outnames_idx,"w");
  
  std::map <char*,int,ltstr> mm;//simple structure to check that input has been sorted by chr/contig
  tary<char> *keep =init<char>();
  tary<char> *major = NULL;
  tary<char> *minor = NULL;
  char *last=NULL;
  int nCols = -1;
  int hasMajMin=0;
  char buf[LENS];

  extern int SIG_COND;
  const char *delims="\t \n";
  char **parsed = new char*[4];
  
  //read a line
  while(SIG_COND && gzgets(gz,buf,LENS)) {
    if(buf[0]=='#'||buf[0]=='\n')//skip if empty or starts with #
      continue;
    
    int nRead=0;
    parsed[nRead++]=strtok(buf,delims);

    char *tok=NULL;
    while(((tok=strtok(NULL,delims)))){
      parsed[nRead++]=tok;
    }
    //it is now tokenized int int parsed
#if 0
    fprintf(stderr,"nRead:%d\n",nRead);
    for(int i=0;i<nRead;i++)
      fprintf(stderr,"c[%d] -> %s\n",i,parsed[i]);
    exit(0);
#endif
    
    //check that we have the same number of columsn acroos all lines
    if(nCols==-1){
      nCols=nRead;
      if(nRead==4){
	hasMajMin =1;
	major= init<char>();
	minor= init<char>();
      }
    }else if(nCols!=nRead){
      fprintf(stderr,"\t-> Problem with number of columns in file. Should be 2,3,4 for entire file (%d vs %d)\n",nCols,nRead);
      SIG_COND=0;goto cleanup;
    }
    
   
    //dump
    if(last!=NULL && strcmp(last,parsed[0])){
      //situation:= we have a change of chr, so we DUMP the data
      if(writeDat(last,mm,keep,major,minor,cfpD,fp,doCompl)){
	SIG_COND=0;
	goto cleanup;
      }
    }
    
    //if we start a 'new' chr
    if(last==NULL||strcmp(last,parsed[0])){
      free(last);
      last=strdup(parsed[0]);
      memset(keep->d,0,keep->m);
      keep->l=0;
      if(hasMajMin){
	memset(major->d,4,keep->m);
	memset(minor->d,4,keep->m);
	major->l=minor->l=0;
      }
    }
    char *position_in_sites_file = parsed[1];
    assert(atol(position_in_sites_file)>=0);
    size_t posS=atol(parsed[1]);
    assert(posS>0);
    posS--;
    posS += posi_off;
    set<char>(keep,posS,1);
    //fprintf(stderr,"keep->l:%lu val:%d\n",keep->l,keep->d[posS]);
    if(nCols==3){
      size_t posE=atol(parsed[2]);
      //posE += posE;
      if(posS>posE){
	fprintf(stderr,"Problem parsing bedfile, end position looks before start position: %lu vs %lu\n",posS,posE);
	exit(0);
      }
      for(size_t ii=posS;ii<posE;ii++)
	set<char>(keep,ii,1);
    }
    if(nCols==4){
      //      fprintf(stderr,"This is the maj/min style\n");
      int al1 = refToInt[parsed[2][0]];
      int al2 = refToInt[parsed[3][0]];
      //      fprintf(stderr,"al1:%d al2:%d\n",al1,al2);
      if(al1==al2||al1==4||al2==4){
	fprintf(stderr,"\t-> major and minor allele should be different, and should be non \'n'/'N' chr:\'%s\' pos:%lu\n",last,posS+1);
	SIG_COND=0;
	goto cleanup;
      }
      set<char>(major,posS,al1);
      set<char>(minor,posS,al2);
    }
  }
  //now after parsing all files
  if(last!=NULL){
    if(writeDat(last,mm,keep,major,minor,cfpD,fp,doCompl)){
	SIG_COND=0;
	goto cleanup;
    }
    free(last);
    last=NULL;
  }

  fprintf(stderr,"\t-> Filtering complete: Observed: %lu different chromosomes from file:%s\n",mm.size(),fname);

  for(mmap::iterator it=mm.begin();it!=mm.end();++it)
    free(it->first);


  mm.clear();
 cleanup:
  if(gz) gzclose(gz);
  if(fp) fclose(fp);
  if(cfpD) bgzf_close(cfpD);
  
  if(SIG_COND==0){
    fprintf(stderr,"\n\t-> CTRL+C was detected, we will therefore assume that the build of the binary filterfiles are incomplete.\n\t-> Will therefore delete: \'%s\',\'%s\'\n",outnames_bin,outnames_idx);
    unlink(outnames_bin);
    unlink(outnames_idx);
    exit(0);
  }
  delete [] parsed;
  delete [] outnames_idx;delete [] outnames_bin;
  dalloc(keep);
  if(major)
    dalloc(major);
  if(minor)
    dalloc(minor);
}
コード例 #7
0
ファイル: prime.cpp プロジェクト: sogolbl/cs569sp15
void main()
{
		
	writeDat();

}