当前位置: 首页>>代码示例>>C++>>正文


C++ printf函数代码示例

本文整理汇总了C++中printf函数的典型用法代码示例。如果您正苦于以下问题:C++ printf函数的具体用法?C++ printf怎么用?C++ printf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    vartable_t *table;
    sfip_var_t *var;
    sfip_t *ip;

    puts("********************************************************************");
    puts("Testing variable table parsing:");
    table = sfvt_alloc_table();
    /* These are all valid */
    TEST(sfvt_add_str(table, "foo [ 1.2.0.0/16, ffff:dead:beef::0 ] ", &var) == SFIP_SUCCESS);
    TEST(sfvt_add_str(table, " goo [ ffff:dead:beef::0 ] ", &var) == SFIP_SUCCESS);
    TEST(sfvt_add_str(table, " moo [ any ] ", &var) == SFIP_SUCCESS);

    /* Test variable redefine */
    TEST(sfvt_add_str(table, " goo [ 192.168.0.1, 192.168.0.2, 192.168.255.0 255.255.248.0 ] ", &var) == SFIP_DUPLICATE);

    /* These should fail since it's a variable name with bogus arguments */
    TEST(sfvt_add_str(table, " phlegm ", &var) == SFIP_FAILURE);
    TEST(sfvt_add_str(table, " phlegm [", &var) == SFIP_FAILURE);
    TEST(sfvt_add_str(table, " phlegm [ ", &var) == SFIP_FAILURE);
    TEST(sfvt_add_str(table, " phlegm [sdfg ", &var) == SFIP_FAILURE);
    TEST(sfvt_add_str(table, " phlegm [ sdfg, 12.123.1.4.5 }", &var) == SFIP_FAILURE);
    TEST(sfvt_add_str(table, " [ 12.123.1.4.5 ]", &var) == SFIP_FAILURE);
    TEST(sfvt_add_str(table, NULL, &var) == SFIP_FAILURE);
    TEST(sfvt_add_str(table, "", &var) == SFIP_FAILURE);

    puts("");
    puts("********************************************************************");
    puts("Expansions:");
    /* Note: used this way leaks memory */
    printf("\t%s\n", sfvt_alloc_expanded(table, "$foo"));
    printf("\t%s\n", sfvt_alloc_expanded(table, "goo $goo sf sfasdfasdf $moo"));
    printf("\t%s\n", sfvt_alloc_expanded(table, " ssdf $moo $moo asdf $fooadff $foo "));
    printf("\t%s\n", sfvt_alloc_expanded(table, " ssdf $moo $moo\\sdf $foo adff"));

    puts("");
    puts("********************************************************************");
    puts("Containment checks:");
    var = sfvt_lookup(table, "goo");
    ip = sfip_alloc("192.168.248.255");
    TEST(sfvar_ip_in(var, ip) == SFIP_SUCCESS);

    /* Check against the 'any' variable */
    var = sfvt_lookup_var(table, "moo");
    TEST(sfvar_ip_in(var, ip) == SFIP_SUCCESS);

    /* Verify it's not in this variable */
    var = sfvt_lookup_var(table, "foo");
    TEST(sfvar_ip_in(var, ip) == SFIP_FAILURE);

    /* Check boundary cases */
    var = sfvt_lookup_var(table, "goo");
    free_ip(ip);
    ip = sfip_alloc_str("192.168.0.3");
    TEST(sfvar_ip_in(var, ip) == SFIP_FAILURE);
    free_ip(ip);
    ip = sfip_alloc_str("192.168.0.2");
    TEST(sfvar_ip_in(var, ip) == SFIP_SUCCESS);


    puts("");
    puts("********************************************************************");

    printf("\n\tTotal Failures: %d\n", failures);
    return 0;
}
开发者ID:Makthum,项目名称:snort,代码行数:67,代码来源:sf_vartable.c

示例2: main


//.........这里部分代码省略.........
			        cp, &ldc );
		}
		else if ( bli_is_double( dt ) )
		{
			f77_int  mm     = bli_obj_length( &c );
			f77_int  nn     = bli_obj_width( &c );
			f77_int  lda    = bli_obj_col_stride( &a );
			f77_int  ldc    = bli_obj_col_stride( &c );
			double*  alphap = bli_obj_buffer( &alpha );
			double*  ap     = bli_obj_buffer( &a );
			double*  cp     = bli_obj_buffer( &c );

			dtrsm_( &f77_side,
			        &f77_uploa,
			        &f77_transa,
			        &f77_diaga,
			        &mm,
			        &nn,
			        alphap,
			        ap, &lda,
			        cp, &ldc );
		}
		else if ( bli_is_scomplex( dt ) )
		{
			f77_int  mm     = bli_obj_length( &c );
			f77_int  nn     = bli_obj_width( &c );
			f77_int  lda    = bli_obj_col_stride( &a );
			f77_int  ldc    = bli_obj_col_stride( &c );
			scomplex*  alphap = bli_obj_buffer( &alpha );
			scomplex*  ap     = bli_obj_buffer( &a );
			scomplex*  cp     = bli_obj_buffer( &c );

			ctrsm_( &f77_side,
			        &f77_uploa,
			        &f77_transa,
			        &f77_diaga,
			        &mm,
			        &nn,
			        alphap,
			        ap, &lda,
			        cp, &ldc );
		}
		else if ( bli_is_dcomplex( dt ) )
		{
			f77_int  mm     = bli_obj_length( &c );
			f77_int  nn     = bli_obj_width( &c );
			f77_int  lda    = bli_obj_col_stride( &a );
			f77_int  ldc    = bli_obj_col_stride( &c );
			dcomplex*  alphap = bli_obj_buffer( &alpha );
			dcomplex*  ap     = bli_obj_buffer( &a );
			dcomplex*  cp     = bli_obj_buffer( &c );

			ztrsm_( &f77_side,
			        &f77_uploa,
			        &f77_transa,
			        &f77_diaga,
			        &mm,
			        &nn,
			        alphap,
			        ap, &lda,
			        cp, &ldc );
		}
#endif

#ifdef PRINT
			bli_printm( "c after", &c, "%9.5f", "" );
			exit(1);
#endif

			dtime_save = bli_clock_min_diff( dtime_save, dtime );
		}

		if ( bli_is_left( side ) )
			gflops = ( 1.0 * m * m * n ) / ( dtime_save * 1.0e9 );
		else
			gflops = ( 1.0 * m * n * n ) / ( dtime_save * 1.0e9 );

		if ( bli_is_complex( dt ) ) gflops *= 4.0;

#ifdef BLIS
		printf( "data_trsm_blis" );
#else
		printf( "data_trsm_%s", BLAS );
#endif
		printf( "( %2lu, 1:4 ) = [ %4lu %4lu  %10.3e  %6.3f ];\n",
		        ( unsigned long )(p - p_begin + 1)/p_inc + 1,
		        ( unsigned long )m,
		        ( unsigned long )n, dtime_save, gflops );

		bli_obj_free( &alpha );

		bli_obj_free( &a );
		bli_obj_free( &c );
		bli_obj_free( &c_save );
	}

	//bli_finalize();

	return 0;
}
开发者ID:devinamatthews,项目名称:blis,代码行数:101,代码来源:test_trsm.c

示例3: main

int main()
{
    time_t hora;
    struct tm *timeinfo;
    int Nvoos;
    int Ndecolagens;
    int Npousos;
    
    char codigo_voo[7];
    char tipo_voo;
    int combustivel_voo;
    int aviso_voo;
    int pista_voo = 1;
    
    char codigos[64][7] = {"VG3001", "JJ4404", "LN7001", "TG1501",
    "GL7602", "TT1010", "AZ1009", "AZ1008", "AZ1010", "TG1506", "VG3002", "JJ4402", "GL7603",
    "RL7880", "AL0012", "TT4544", "TG1505", "VG3003", "JJ4403", "JJ4401", "LN7002", "AZ1002",
    "AZ1007", "GL7604", "AZ1006", "TG1503", "AZ1003", "JJ4403", "AZ1001", "LN7003", "AZ1004",
    "TG1504", "AZ1005", "TG1502", "GL7601", "TT4500", "RL7801", "JJ4410", "GL7607", "AL0029",
    "VV3390", "VV3392", "GF4681", "GF4690", "AZ1020", "JJ4435", "VG3010", "LF0920", "AZ1065",
    "LF0978", "RL7867", "TT4502", "GL7645", "LF0932", "JJ4434", "TG1510", "TT1020", "AZ1098",
    "BA2312", "VG3030", "BA2304", "KL5609", "KL5610", "KL5611"};
    
    srand(time(NULL));
    
    //Gerador de número de vôos, pousos e decolagens
    Nvoos = geraRand (0, 64);
    Ndecolagens = geraRand (0, Nvoos);
    Npousos = Nvoos - Ndecolagens;
    int voos = 0;
    int dec = Ndecolagens;
    int pouso = Npousos;
     
    FILA fila = cria_fila();
    
    for(voos = 1; voos <= Nvoos; voos++){
             strcpy(codigo_voo, codigos[voos]);
             
             if(pouso > 0 && dec >0){
                      if(geraRand(0,1)){
                                  tipo_voo = 'D';
                                  dec--;
                                  combustivel_voo = geraRand (24, 48);
                                  pista_voo = ((voos-1)%3)+1;
                                  }
                      else{
                           tipo_voo = 'P';
                           pouso--;
                           combustivel_voo = geraRand (0, 12);
                           
                           if (combustivel_voo == 0)
                                                   aviso_voo = 1;
                           
                           else
                                aviso_voo = 0;
                                
                           
                           pista_voo = ((voos - 1)%3) + 1;
                           if(pista_voo == 3 && tipo_voo == 'P' && aviso_voo == 0){
                                        pista_voo = ((voos)%3) + 1;
                                        }
                           }
                      }
                      
             else if (pouso == 0 && dec !=0){
                  tipo_voo = 'D';
                  dec--;
                  combustivel_voo = geraRand (24, 48);
                  pista_voo = ((voos-1)%3) + 1;
                  }
                  
             else if (pouso != 0 && dec == 0){
                  tipo_voo = 'P';
                  pouso--;
                  combustivel_voo = geraRand (0, 12);
                  
                  if (combustivel_voo == 0){
                                          aviso_voo = 1;
                                          }
                  else{
                       aviso_voo = 0;
                       }
                  
                  pista_voo = ((voos - 1)%3) + 1;
                  if(pista_voo == 3 && tipo_voo == 'P' && aviso_voo == 0){
                               pista_voo = ((voos)%3) + 1;
                               }
                  }
                  
             insere_fila(fila, codigo_voo, tipo_voo, combustivel_voo, aviso_voo, pista_voo);
             }
    
    printf ("\n              Aeroporto Internacional de Brasilia\n");
    hora = time(NULL);
    timeinfo = localtime(&hora);
    printf("                   Hora atual: %02d:%02d:%02d\n", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
    printf("                       Fila de pedidos:\n");
    printf("                          Nvoos: %d\n", Nvoos);
    printf("                       Ndecolagens: %d\n", Ndecolagens);
    printf("                         Npousos: %d\n\n", Npousos);
//.........这里部分代码省略.........
开发者ID:Miney,项目名称:Estruturas-de-Dados,代码行数:101,代码来源:proj1-pr10.c

示例4: TEST_CORE_GetVMPageSize

static void TEST_CORE_GetVMPageSize(void)
{
    printf("PageSize = %d\n", (int) CORE_GetVMPageSize());
}
开发者ID:fbtestrepo,项目名称:hw,代码行数:4,代码来源:test_ncbi_core.c

示例5: print

 virtual void print(void) const { printf("B::print\n"); }
开发者ID:0day-ci,项目名称:gcc,代码行数:1,代码来源:p2846a.C

示例6: main

/* ////////////////////////////////////////////////////////////////////////////
   -- Testing zpotrf_mc
*/
int main( magma_int_t argc, char** argv) 
{
    cuDoubleComplex *h_A, *h_R, *h_work, *h_A2;
    cuDoubleComplex *d_A;
    float gpu_perf, cpu_perf, cpu_perf2;

    magma_timestr_t start, end;

    /* Matrix size */
    magma_int_t N=0, n2, lda;
    magma_int_t size[10] = {1024,2048,3072,4032,5184,6048,7200,8064,8928,10080};
    
    magma_int_t i, j, info[1];

    magma_int_t ione     = 1;
    magma_int_t ISEED[4] = {0,0,0,1};

    magma_int_t num_cores = 4;
    int num_gpus = 0;

    magma_int_t loop = argc;
    
    if (argc != 1){
      for(i = 1; i<argc; i++){      
        if (strcmp("-N", argv[i])==0)
          N = atoi(argv[++i]);
        else if (strcmp("-C", argv[i])==0)
          num_cores = atoi(argv[++i]);
      }
      if (N==0) {
        N = size[9];
        loop = 1;
      } else {
        size[0] = size[9] = N;
      }
    } else {
      printf("\nUsage: \n");
      printf("  testing_zpotrf_mc -N %d -B 128 \n\n", 1024);
      N = size[9];
    }

    lda = N;
    n2 = size[9] * size[9];

    /* Allocate host memory for the matrix */
    h_A = (cuDoubleComplex*)malloc(n2 * sizeof(h_A[0]));
    if (h_A == 0) {
        fprintf (stderr, "!!!! host memory allocation error (A)\n");
    }

    /* Allocate host memory for the matrix */
    h_A2 = (cuDoubleComplex*)malloc(n2 * sizeof(h_A2[0]));
    if (h_A2 == 0) {
        fprintf (stderr, "!!!! host memory allocation error (A2)\n");
    }

    /* Initialize MAGMA hardware context, seeting how many CPU cores 
       and how many GPUs to be used in the consequent computations  */
    magma_context *context;
    context = magma_init(NULL, NULL, 0, num_cores, num_gpus, argc, argv);

    
    printf("\n\n");
    printf("  N    Multicore GFlop/s    ||R||_F / ||A||_F\n");
    printf("=============================================\n");
    for(i=0; i<10; i++)
      {
    N = lda = size[i];
    n2 = N*N;

    lapackf77_zlarnv( &ione, ISEED, &n2, h_A );
    
    for(j=0; j<N; j++) 
      MAGMA_Z_SET2REAL( h_A[j*lda+j], ( MAGMA_Z_GET_X(h_A[j*lda+j]) + 2000. ) );

    for(j=0; j<n2; j++)
      h_A2[j] = h_A[j];

    /* =====================================================================
       Performs operation using LAPACK 
       =================================================================== */

    //lapackf77_zpotrf("L", &N, h_A, &lda, info);
    lapackf77_zpotrf("U", &N, h_A, &lda, info);
    
    if (info[0] < 0)  
      printf("Argument %d of zpotrf had an illegal value.\n", -info[0]);     

    /* =====================================================================
       Performs operation using multi-core 
       =================================================================== */
    start = get_current_time();
    //magma_zpotrf_mc(context, "L", &N, h_A2, &lda, info);
    magma_zpotrf_mc(context, "U", &N, h_A2, &lda, info);
    end = get_current_time();
    
    if (info[0] < 0)  
//.........这里部分代码省略.........
开发者ID:soulsheng,项目名称:magma,代码行数:101,代码来源:testing_zpotrf_mc.cpp

示例7: TEST_CORE_LogCleanup

/* FLOG_Cleanup */
static void TEST_CORE_LogCleanup(void* user_data)
{
  assert(user_data == &TEST_CORE_LogUserData);
  printf("TEST_CORE_LogCleanup(round %d)\n", TEST_CORE_LogUserData);
  TEST_CORE_LogUserData = 444;
}
开发者ID:fbtestrepo,项目名称:hw,代码行数:7,代码来源:test_ncbi_core.c

示例8: main

/* Main Function acting as a client for Image Encode Call*/
XDAS_Int32 main(int argc, char *argv[])
{

    /* File I/O variables */
    FILE *fConfigFile, /**ftestFile, *finFile,*/ *fparamsFile;

#ifdef LINUX
    CMEM_AllocParams memParams;
    memParams.type=CMEM_POOL;
    memParams.flags=CMEM_NONCACHED;
    memParams.alignment=256;
#endif

    char* colorf[]={"YUV422P", "YUV420P", "YUV422P", "YUV422IL", "YUV422IL", "YUV444", "YUV411", "GRAY", "RGB", "YUV420_LINE"};
#ifdef LINUX
    XDAS_Int8 *fname = "../TestVecs/Config/Testvecs.cfg";
#else
    XDAS_Int8 *fname = "..\\..\\Test\\TestVecs\\Config\\Testvecs_ccs.cfg";
#endif
    Int32 lTemp,countConfigSet;
    Int32 retVal;
    Uint32 numAU, totalAU,repeat;
    Uint32 bytesGenerated;
    Uint16 mbSizeX, mbSizeY,mbY;

    char *RefBuffPtr;
    FILE *fp_out;
    FILE *fp_in;
    int processTime = 0, processTimeTotal = 0,algActivateTime =0, algDeactivateTime =0,copctime=0;
    int val,queue_word,queue_num=0,i,k;
    char baseParams[STRING_SIZE];
    int baseParamsOnly;
    int Offset;
    int num_markers;
    IIMGENC1_Fxns            *iimgEncfxns;
    IIMGENC1_Status  imgencStatus;
    IIMGENC1_InArgs imgencInArgs;
    IIMGENC1_OutArgs imgencOutArgs;
    IJPEGENC_Status          status;
    IJPEGENC_InArgs          inArgs;
    IJPEGENC_OutArgs         outArgs;
    unsigned int lTemp1;

    /*Algorithm specific handle */
    IALG_Handle handle;

    /* Input/Output Buffer Descriptor variables */
    XDM1_BufDesc inputBufDesc, outputBufDesc;


#ifdef ENABLE_RMAN // IRES/RMAN Related declarations
    // temp_trace_init();
    IRES_Status iresStatus;
    Int size =0;
    Int scratchId =0;
    Bool result = TRUE;
    IRES_Fxns *resFxns = &JPEGENC_TI_IRES;
    IRESMAN_Edma3ChanParams configParams;
    IRESMAN_VicpParams iresmanConfigParams;
    IRESMAN_AddrSpaceParams addrspaceConfigParams;

    iresStatus = RMAN_init();
    if (IRES_OK != iresStatus) {
        printf("RMAN initialization Failed \n");
        return -1;
    }
    printf("RMAN initialization done \n");

#ifndef LINUX
        /* Call the functions to enable ARM926 FIQ and do some basic
         * setup to AINTC to accept KLD INTC (arm968) interupt in 
         * FIQ pin of Arm926  
         */
        ARM926_enable_FIQ();  /* SWI call to enable interrupts */
        ARM926_INTC_init();  /* Init AINTC */
#endif

    /*
     * Supply initialization information for the RESMAN while registering
     */
    size = sizeof(IRESMAN_VicpParams);

    iresmanConfigParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn;
    iresmanConfigParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn;
    iresmanConfigParams.baseConfig.size = size;

    /* Register the VICP protocol/resource manager with the
    *      * generic resource manager */

    iresStatus = RMAN_register(&IRESMAN_VICP2, (IRESMAN_Params *)&iresmanConfigParams);

    if (IRES_OK != iresStatus) {
        printf("VICP Protocol Registration Failed \n");
        return -1;
    }
    printf("VICP Protocol Registration Success \n");
    /*
     *      * Supply initialization information for the EDMA3 RESMAN while registering
     *           */
//.........这里部分代码省略.........
开发者ID:andreimironenko,项目名称:codecs-dm365,代码行数:101,代码来源:jpgeTestApp.c

示例9: fread

cibar_t *cibar_open(FILE *f)
{
  cibar_internal_file_entry_t *entries;
  char *strings;
  uint8_t *data;
  cibar_internal_t cb;
  cibar_t *out;
  int i;

  if (!f)
    return NULL;

  /* Read the header */
  fread(&cb, sizeof(cibar_internal_t), 1, f);

  if (cb.magic != 0x12344321)
    {
      printf("cibar: Wrong magic: 0x%08x\n", cb.magic);
      goto error_1;
    }

  /* Allocate structures */
  if ( !(entries = (cibar_internal_file_entry_t*)malloc(sizeof(cibar_internal_file_entry_t) * cb.n_file_entries)) )
    goto error_1;
  if ( !(strings = (char*)malloc( cb.strtab_length )) )
    goto error_2;
  if ( !(data = (uint8_t*)malloc( cb.data_length )) )
    goto error_3;
  if ( !(out = (cibar_t*)malloc( sizeof(cibar_t) + sizeof(cibar_file_entry_t) * cb.n_file_entries)) )
    goto error_4;

  /* Read the rest of the file */
  if (fread(entries, 1, sizeof(cibar_internal_file_entry_t) * cb.n_file_entries, f) !=
      sizeof(cibar_internal_file_entry_t) * cb.n_file_entries)
    goto error_4;
  if (fread(strings, 1, cb.strtab_length, f) != cb.strtab_length)
    goto error_4;
  if (fread(data, 1, cb.data_length, f) != cb.data_length)
    goto error_4;

  /* Fill in the out stucture */
  out->n_files = cb.n_file_entries;
  out->strings = strings;
  out->data = data;
  for (i = 0; i < cb.n_file_entries; i++)
    {
      cibar_file_entry_t *p = &out->files[i];

      p->cibar = out;
      p->data = data + entries[i].data_offset;
      p->data_size = entries[i].data_size;
      p->name = strings + entries[i].strtab_offset;
    }

  free(entries);

  return out;
 error_4:
  free(data);
 error_3:
  free(strings);
 error_2:
  free(entries);
 error_1:
  return NULL;
}
开发者ID:NoamSheffer,项目名称:WazeWP7,代码行数:66,代码来源:cibar.c

示例10: main


//.........这里部分代码省略.........
	  continue;
	}
      else
	{
	  while(event_number == temp_evtn)
	    {
	      // std::cout << "I'm in the loop. ROC " << roc_in << std::endl;
	      if(roc_out == ROC_DUT)
		{
		  ++nhits;
		}
	      ++i;
	      if(i == DFoutput->GetEntries()) break;
	      DFoutput->GetEntry(i);
	      // std::cout << "Entry: " << i << "Event " << event_number << "ROC " << roc_out <<   std::endl;

	    }

	  --i;
	  Pixels_per_Event_out->Fill(nhits);
	  //	  std::cout << "Found event with " << nhits << "Hits on ROC " << ROC_DUT << std::endl;
	  nhits = 0;

	}

    }

  c1->cd(2);
  Pixels_per_Event_out->Draw();
  c1->Update();

  //picking up the 3rd histogram
  TFile * simAnaFile = new TFile(SimFile,"READ");
  if ( simAnaFile->IsOpen()) printf("File opened successfully\n");				    
  
				    
  char histname[256];
  sprintf(histname,"MyCMSPixelClusteringProcessor/detector_3/pixelPerEvent_d%i",ROC_DUT);

  std::cout << histname << std::endl;

  TH1I * Hits_per_Event_sim;

  Hits_per_Event_sim=(TH1I*)simAnaFile->Get("MyCMSPixelClusteringProcessor/detector_3/pixelPerEvent_d3");
  
  c1->cd(3);
 
  Hits_per_Event_sim->GetXaxis()->SetRangeUser(0,20);
 
  Hits_per_Event_sim->SetTitle("Analysis of simulated data");
 
  Hits_per_Event_sim->Draw();

  c1->Update();


  //pick up the last "original" histogram

  TFile * realAnaFile = new TFile(AnaFile,"READ");
  if ( realAnaFile->IsOpen()) printf("File opened successfully\n");				    
  
				    
  sprintf(histname,"MyCMSPixelClusteringProcessor/detector_3/pixelPerEvent_d%i",ROC_DUT);

  TH1I * Hits_per_Event_ana;
开发者ID:akornmay,项目名称:usercode,代码行数:66,代码来源:comparison_compile.cpp

示例11: main

int
main (void)
{
  int year, month, day;
  double lon, lat;
  double len, rise, set, cur_time;
  int rc;
  char ch;
  time_t t;
  struct tm *tm;

  t = time (NULL);
  tm = gmtime (&t);
  lon = 0;

  sun_rise_set (tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
		lon, 0.0, &rise, &set);
  cur_time = tm->tm_hour + tm->tm_min / 60.0;
  lon += (rise - cur_time) * 15.0;
  if (lon > 180.0)
    lon -= 360.0;
  if (lon < -180.0)
    lon += 360.0;

  printf ("==> Sun is rising at longitude %5.2fE, latitude 0.00N\n", lon);

  printf ("Longitude (+ is east) and latitude (+ is north), or * for Lugano: ");
  ch = getchar ();
  if (ch == '*')
    lon = 8.0 + 57.0/60.0, lat = 46.0;
  else
    {
      ungetc (ch, stdin);
      while (scanf ("%lf %lf", &lon, &lat) < 2)
	;
    }

  tm = localtime (&t);
  year = tm->tm_year + 1900;
  month = tm->tm_mon + 1;
  day = tm->tm_mday;
  do
    {
      len = day_length (year, month, day, lon, lat);
      printf ("==> Day length: %5.2f hours\n", len);

      rc = sun_rise_set (year, month, day, lon, lat, &rise, &set);
      if (rc == 1)
	printf ("==> Sun never sets!\n");
      else if (rc == -1)
	printf ("==> Sun never rises!\n");
      else
	{
	  printf ("==> Midday: %5.2f GMT\n", (rise + set) / 2);
	  printf ("==> Sunrise: %5.2f, Sunset: %5.2f GMT\n", rise, set);
	}

      rc = civil_rise_set (year, month, day, lon, lat, &rise, &set);
      if (rc == 1)
	printf ("==> Sun never reaches civil dusk!\n");
      else if (rc == -1)
	printf ("==> Sun never reaches civil dawn!\n");
      else
	printf ("==> Civil sunrise: %5.2f, Sunset: %5.2f GMT\n", rise, set);

      printf ("Date (yyyy mm dd) (ctrl-C exits): ");
      while (scanf ("%d %d %d", &year, &month, &day) < 3 && !feof (stdin))
	;
    }
  while (!feof (stdin));
  return 0;
}
开发者ID:bonzini,项目名称:earthview,代码行数:72,代码来源:sunrise-test.c

示例12: main_line_removal

int main_line_removal() {
	PIX* pixs_source = pixRead("dave-start.png");
	if (!pixs_source) {
		printf("Error opening file");
		return 1;
	}


	double deg2rad = 3.1415926535 / 180.;
	l_float32    angle, conf, score;

	PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pix6, *pix7, *pix8, *pix9;

	pix1 = pixThresholdToBinary(pixs_source, 160);
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-1.tif", pix1, IFF_TIFF_G4);

	pixFindSkew(pix1, &angle, &conf);
	pix2 = pixRotateAMGray(pixs_source, deg2rad * angle, 160);
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-2.tif", pix2, IFF_TIFF_G4);

	l_int32 HORIZ = 1;
	l_int32 VERT = 3;
	pix3 = pixCloseGray(pix2, 51, HORIZ); //k?p?c 51?
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-3.tif", pix3, IFF_TIFF_G4);

	pix4 = pixErodeGray(pix3, 5, VERT); //k?p?c 5?
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-4.tif", pix4, IFF_TIFF_G4);


	pix5 = pix4;
	pix5 = pixThresholdToValue(pix5, pix4, 230, 255);
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-5.tif", pix5, IFF_TIFF_G4);

	pix6 = pix5;
	pix6 = pixThresholdToValue(pix5, pix5, 210, 0);
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-6.tif", pix6, IFF_TIFF_G4);

	pix7 = pixThresholdToBinary(pix6, 230);
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-7.tif", pix7, IFF_TIFF_G4);
	
	pixInvert(pix6, pix6);
	pix8 = pixAddGray(NULL, pix2, pix6);
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-8.tif", pix8, IFF_TIFF_G4);

	VERT = 7;
	pix9 = pixOpenGray(pix8, 3, VERT);
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-9.tif", pix9, IFF_TIFF_G4);

	if (pixCombineMasked(pix8, pix9, pix7)) {
		printf("!!!Error while combining pixs!!!\n");
	}
	printf("Create line removal image\n");
	pixWrite("line-removal/result.line-removal-final.tif", pix8, IFF_TIFF_G4);


	printf("\n---\nEnd\n");
	getchar();
	return 0;
}
开发者ID:PeterLauris,项目名称:OCR,代码行数:68,代码来源:line-removal.cpp

示例13: test_sort_unique_find_search

void test_sort_unique_find_search(void)
{
     uint random_size;
    
     random_size = rand() % MAX_LIST_SIZE;
     List zeros = list_create(random_size);
     printf("Zero List ::: ");
     list_print(&zeros);

     List list = list_random(MAX_LIST_SIZE, ELEMENT_MAX_VALUE);
     printf("%sRandom List ::: ", cyan);
     list_print(&list);

     list_sort_by_item(&list);
     printf("%sList Resorted By Item ::: ", red);
     list_print(&list);
     
     printf("%sUnique List ::: ", magenta);
     list_unique(&list);
     list_print(&list);

     list_sort_by_frequency_back(&list);
     printf("%sList Sorted Backward By Frequency ::: ",green);
     list_print(&list);

     list_sort_by_frequency(&list);
     printf("%sList Resorted By Frequency ::: ", blue);
     list_print(&list);
     
     Item query = list.data[rand() % list.size];
     Item *found = list_find(&list, query);
     if (found != NULL)
          printf("%sFind function: %d found in position %d\n", brown, query.item, (int)(found - list.data));    
     else
          printf("%sFind function: %d not found", brown, query.item);
 
     list_sort_by_item_back(&list);
     printf("%sList Sorted Backwards By Item ::: ", black);
     list_print(&list);

     list_sort_by_item(&list);
     printf("%sList Resorted By Item ::: ", cyan);
     list_print(&list);

     query = list.data[rand() % list.size];
     found = list_binary_search(&list, query);
     printf("%sBinary search: %d found in position %d\n", none, query.item, (int)(found - list.data));    
}
开发者ID:caomw,项目名称:Sampled-MinHashing,代码行数:48,代码来源:test_array_lists.c

示例14: test_concat_append_add_union_intersection_difference

void test_concat_append_add_union_intersection_difference(void)
{     
     List list1 = list_random(MAX_LIST_SIZE, ELEMENT_MAX_VALUE);
     list_sort_by_item(&list1);
     list_unique(&list1);
     printf("Original List 1 ::: ");
     list_print(&list1);

     List list2 = list_random(MAX_LIST_SIZE, ELEMENT_MAX_VALUE);
     list_sort_by_item(&list2);
     list_unique(&list2);
     printf("%sOriginal List 2 ::: ", brown);
     list_print(&list2);

     List concat = list_concat(&list1, &list2);
     printf("%sConcatenation List ::: ", cyan);
     list_print(&concat);

     List append = list_duplicate(&list1);
     list_append(&append, &list2);
     printf("%sList 1 appended to list 2 ::: ", magenta);
     list_print(&append);
     
     List add = list_duplicate(&list1);
     list_add(&add, &list2);
     printf("%sList 1 added to list 2 ::: ", green);
     list_print(&add);

     List union_list = list_union(&list1, &list2);	
     printf("%sList Union ::: ", blue);
     list_print(&union_list);

     List intersection_list = list_intersection(&list1, &list2);
     printf("%sList Intersection ::: ", red);
     list_print(&intersection_list);

     List difference_list = list_difference(&list1, &list2);
     printf("%sDifference List ::: ", cyan);
     list_print(&difference_list);

     uint union_size = list_union_size(&list1, &list2);
     printf("%sList Union Size = %d\n", brown, union_size);

     uint intersection_size = list_intersection_size(&list1, &list2);
     printf("%sList Intersection Size = %d\n", black, intersection_size);

     uint difference_size = list_difference_size(&list1, &list2);
     printf("%sList Difference Size = %d\n", black, difference_size);
     
     printf("%s",none);

}
开发者ID:caomw,项目名称:Sampled-MinHashing,代码行数:52,代码来源:test_array_lists.c

示例15: kernel_main

int kernel_main() {
    init_gdt();
    init_idt();
    init_video();

    setcolor(make_color(COLOR_GREEN, COLOR_BLACK));
    printf("Hello, World!");
    newline(5);
    setcolor(make_color(COLOR_ORANGE, COLOR_BLACK));
    printf("                          ,--.\n");
    printf("                   _/ <`-'\n");
    printf("               ,-.' \\--\\_\n");
    printf("              ((`-.__\\   )\n");
    printf("               \\`'    @ (_\n");
    printf("               (        (_)\n");
    printf("              ,'`-._(`-._/\n");
    printf("           ,-'    )&&) ))\n");
    printf("        ,-'      /&&&%-'\n");
    printf("      ,' __  ,- {&&&&/\n");
    printf("     / ,'  \\|   |\\&&'\\\n");
    printf("    (       |   |' \\  `--.\n");
    printf("(%--'\\   ,--.\\   `-.`-._)))\n");
    printf(" `---'`-/__)))`-._)))\n\n");

    int count = 0;

    //Some delay before bouncing
    while (count < 10) {
        sleep(100000000);
        count++;
    }
    count = 0;
    while (true) {

        while (count < 5) {
            sleep(100000000);
            scrolldown();
            count++;
        }

        while (count < 10) {
            sleep(100000000);
            scrollup();
            count++;

        }

        if (count % 10 == 0) {
            count = 0;
        }

    }
    printf("Exiting...");


    return 0;
}
开发者ID:Aweosme,项目名称:TwitchOS,代码行数:57,代码来源:main.c


注:本文中的printf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。