main(){ int a =0,b=0; char wordSearch[R][C] ={"\0"}; char keyword[KEY][KEYLEN] ={"\0"}; srand(time(NULL)); getWords(keyword); fits(wordSearch, keyword); printf("\n"); for(a=0; a<R;a++){ for(b=0;b<C;b++){ printf("%c", wordSearch[a][b]); } printf("\n"); } printf("\n\n\n"); pause; displayPuzzle(wordSearch, keyword); pause; }
/***********************************************************************//** * @brief Load livetime cube from FITS file * * @param[in] filename FITS file name. * * @todo Loading of cos theta boundaries not yet implemented. This is not * critical since they are not really needed. We just need them once * we want to implement also saving. ***************************************************************************/ void GLATLtCube::load(const GFilename& filename) { // Clear object clear(); // Open livetime cube FITS file GFits fits(filename); // Get HDUs const GFitsTable& hdu_exposure = *fits.table(gammalib::extname_lat_exposure); const GFitsTable& hdu_weighted_exposure = *fits.table(gammalib::extname_lat_wgtexposure); //const GFitsTable& hdu_cthetabounds = *fits.table(gammalib::extname_lat_cthetabounds); const GFitsTable& hdu_gti = *fits.table(gammalib::extname_gti); // Load exposure m_exposure.read(hdu_exposure); // Load weighted exposure m_weighted_exposure.read(hdu_weighted_exposure); // Load cos theta boundaries // Load GTIs m_gti.read(hdu_gti); // Close FITS file fits.close(); // Return return; }
static int want_write (int type, void *ptr) { struct lev_generic *E = ptr; switch (type) { case LEV_START: return !targ_existed++ && !jump_log_pos; case LEV_NOOP: return 0; case LEV_TIMESTAMP: case LEV_CRC32: case LEV_ROTATE_TO: case LEV_ROTATE_FROM: return 0; case LEV_STATS_VIEWS ... LEV_STATS_VIEWS + 0xff: case LEV_STATS_COUNTER_ON: case LEV_STATS_COUNTER_OFF: case LEV_STATS_TIMEZONE ... LEV_STATS_TIMEZONE + 0xff: case LEV_STATS_VIEWS_EXT: case LEV_STATS_VISITOR_OLD: case LEV_STATS_VISITOR ... LEV_STATS_VISITOR + 0xff: case LEV_STATS_VISITOR_VERSION: case LEV_STATS_VISITOR_OLD_EXT: case LEV_STATS_VISITOR_EXT ... LEV_STATS_VISITOR_EXT + 0xff: return fits (E->a); default: assert (0); } }
int main() { int i; i64 a, b, x, y, t; scanf("%d", &i); while(i--) { scanf("%lld %lld %lld %lld", &a, &b, &x, &y); if( a < b ) { t = a; a = b; b = t; } if( x < y ) { t = x; x = y; y = t; } if( fits(a, b, x, y) ) printf("Escape is possible.\n"); else printf("Box cannot be dropped.\n"); } return 0; }
/***********************************************************************//** * @brief Load Pulse Height Analyzer spectrum * * @param[in] filename File name. * * Loads the Pulse Height Analyzer spectrum from the `SPECTRUM` extension * of the FITS file. If the file contains also an `EBOUNDS` extension the * energy boundaries of all Pulse Height Analyzer channels are also loaded. ***************************************************************************/ void GPha::load(const GFilename& filename) { // Clear spectrum clear(); // Open FITS file (without extension name as the user is not allowed // to modify the extension names) GFits fits(filename.url()); // Get PHA table const GFitsTable& pha = *fits.table("SPECTRUM"); // Read PHA data read(pha); // Optionally read EBOUNDS data if (fits.contains("EBOUNDS")) { // Get EBOUNDS table const GFitsTable& ebounds = *fits.table("EBOUNDS"); // Read EBOUNDS data m_ebounds.read(ebounds); } // endif: has EBOUNDS table // Close FITS file fits.close(); // Store filename m_filename = filename.url(); // Return return; }
/***********************************************************************//** * @brief Load spectrum * * @param[in] filename File name. * * This method loads a spectrum from a variety of file types. The method * analyses the format of the file that is presented and choses then the * appropriate method to load the specific format. The following file * formats are supported: FITS, TBW ... * * @todo So far only FITS file support is implemented. ***************************************************************************/ void GMWLSpectrum::load(const GFilename& filename) { // Clear object clear(); // Open FITS file GFits fits(filename); // Read spectrum if (filename.has_extno()) { read(fits, filename.extno()); } else if (filename.has_extname()) { read(fits, filename.extname()); } else { read(fits); } // Close FITS file fits.close(); // Return return; }
/***********************************************************************//** * @brief Save point spread function table into FITS file * * @param[in] filename FITS file name. * @param[in] clobber Overwrite existing file? (default: false) * * Saves point spread function into a FITS file. If a file with the given * @p filename does not yet exist it will be created, otherwise the method * opens the existing file. The method will create a (or replace an existing) * point spread function extension. The extension name can be specified as * part of the @p filename, or if no extension name is given, is assumed to * be "POINT SPREAD FUNCTION". * * An existing file will only be modified if the @p clobber flag is set to * true. ***************************************************************************/ void GCTAPsfTable::save(const GFilename& filename, const bool& clobber) const { // Get extension name std::string extname = filename.extname("POINT SPREAD FUNCTION"); // Open or create FITS file (without extension name since the requested // extension may not yet exist in the file) GFits fits(filename.url(), true); // Remove extension if it exists already if (fits.contains(extname)) { fits.remove(extname); } // Create binary table GFitsBinTable table; // Write the background table write(table); // Set binary table extension name table.extname(extname); // Append table to FITS file fits.append(table); // Save to file fits.save(clobber); // Return return; }
bool deep_fsck(block_getter_t *getter, const void *value, int length_available, std::string *msg_out) const { if (!fits(value, length_available)) { *msg_out = "value does not fit in length_available"; return false; } return blob::deep_fsck(getter, block_size_, as_memcached(value)->value_ref(), blob::btree_maxreflen, msg_out); }
void *smalloc(int bytes) { Chunk c = H; while (!fits(c, bytes)) c = c->next; if (c) { return split(c, bytes); } else { return NULL; } }
void MaxRects::add(RectData* data, unsigned int w, unsigned int h) { if (!fits(w, h, m_config.m_width, m_config.m_height, m_config.m_canFlip)) throw std::runtime_error("rectangle doesn't fit"); *data = { 0, 0, w, h, false, 0 }; if (data->m_w != 0 && data->m_h != 0) m_rectangles.push_back(data); }
/***********************************************************************//** * @brief Load effective area from FITS file * * @param[in] filename FITS file. * * This method loads the effective area information, and if available, the * efficiency factors, from the FITS response file. See the GLATAeff::read * method for details. ***************************************************************************/ void GLATAeff::load(const std::string& filename) { // Open FITS file GFits fits(filename); // Read effective area from file read(fits); // Return return; }
void process_video_row (void) { char *p, *q; int len, i, c; struct lev_search_text_short_entry *LS; struct lev_search_text_long_entry *LL; if (I[vi_source] || I[vi_uploaded] != 1 || I[vi_privacy] || !fits(I[vi_owner_id])) { return; } len = L[vi_title] + L[vi_description] + 1; if (len > 4095) { return; } if (len < 256) { LS = write_alloc (21+len); LS->type = LEV_SEARCH_TEXT_SHORT + len; LS->rate = 0; LS->rate2 = I[vi_duration]; LS->obj_id = (I[vi_id] << 32) + (unsigned) I[vi_owner_id]; q = LS->text; } else { LL = write_alloc (23+len); LL->type = LEV_SEARCH_TEXT_LONG; LL->rate = 0; LL->rate2 = I[vi_duration]; LL->obj_id = (I[vi_id] << 32) + (unsigned) I[vi_owner_id]; LL->text_len = len; q = LL->text; } p = S[vi_title]; for (i = L[vi_title]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = '\t'; p = S[vi_description]; for (i = L[vi_description]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = 0; adj_rec++; }
void process_blog_posts_row (void) { char *p, *q; int len, i, c; struct lev_search_text_short_entry *LS; struct lev_search_text_long_entry *LL; if (!I[bp_id] || !fits(I[bp_user_id]) || I[bp_view_privacy]) { return; } len = L[bp_title] + L[bp_post] + 1; if (len > 49152) { return; } if (len < 256) { LS = write_alloc (21+len); LS->type = LEV_SEARCH_TEXT_SHORT + len; LS->rate = I[bp_date]; LS->rate2 = I[bp_ncom]; LS->obj_id = ((long long) I[bp_id] << 32) + (unsigned) I[bp_user_id]; q = LS->text; } else { LL = write_alloc (23+len); LL->type = LEV_SEARCH_TEXT_LONG; LL->rate = I[bp_date]; LL->rate2 = I[bp_ncom]; LL->obj_id = ((long long) I[bp_id] << 32) + (unsigned) I[bp_user_id]; LL->text_len = len; q = LL->text; } p = S[bp_title]; for (i = L[bp_title]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = '\t'; p = S[bp_post]; for (i = L[bp_post]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = 0; adj_rec++; }
void process_audio_row (void) { char *p, *q; int len, i, c; struct lev_search_text_short_entry *LS; struct lev_search_text_long_entry *LL; if (I[au_source] || !fits(I[au_owner_id])) { return; } len = L[au_performer] + L[au_title] + 1; if (len > 4095) { return; } if (len < 256) { LS = write_alloc (21+len); LS->type = LEV_SEARCH_TEXT_SHORT + len; LS->rate = (I[au_has_lyrics] > 0); LS->rate2 = I[au_duration]; LS->obj_id = (I[au_id] << 32) + (unsigned) I[au_owner_id]; q = LS->text; } else { LL = write_alloc (23+len); LL->type = LEV_SEARCH_TEXT_LONG; LL->rate = (I[au_has_lyrics] > 0); LL->rate2 = I[au_duration]; LL->obj_id = (I[au_id] << 32) + (unsigned) I[au_owner_id]; LL->text_len = len; q = LL->text; } p = S[au_performer]; for (i = L[au_performer]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = '\t'; p = S[au_title]; for (i = L[au_title]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = 0; adj_rec++; }
void process_memlite_row (void) { char *p, *q; int len, i, c; struct lev_search_text_short_entry *LS; struct lev_search_text_long_entry *LL; if (!I[ml_id] || !fits(I[ml_id]) || I[ml_profile_privacy] == 4) { return; } len = L[ml_first_name] + L[ml_last_name] + 1; if (len > 1024) { return; } if (len < 256) { LS = write_alloc (21+len); LS->type = LEV_SEARCH_TEXT_SHORT + len; LS->rate = I[ml_rate]; LS->rate2 = I[ml_cute]; LS->obj_id = I[ml_id]; q = LS->text; } else { LL = write_alloc (23+len); LL->type = LEV_SEARCH_TEXT_LONG; LL->rate = I[ml_rate]; LL->rate2 = I[ml_cute]; LL->obj_id = I[ml_id]; LL->text_len = len; q = LL->text; } p = S[ml_first_name]; for (i = L[ml_first_name]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = '\t'; p = S[ml_last_name]; for (i = L[ml_last_name]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = 0; adj_rec++; }
TEST(Type, TypeConstraints) { EXPECT_TRUE(fits(Type::Gen, DataTypeGeneric)); EXPECT_FALSE(fits(Type::Gen, DataTypeCountness)); EXPECT_FALSE(fits(Type::Gen, DataTypeCountnessInit)); EXPECT_FALSE(fits(Type::Gen, DataTypeSpecific)); EXPECT_FALSE(fits(Type::Gen, TypeConstraint(DataTypeSpecialized).setWantArrayKind())); EXPECT_TRUE(fits(Type::Cell, {DataTypeGeneric})); EXPECT_TRUE(fits(Type::Gen, {DataTypeGeneric})); EXPECT_FALSE(fits(Type::Arr, TypeConstraint(DataTypeSpecialized).setWantArrayKind())); EXPECT_TRUE(fits(Type::Arr.specialize(ArrayData::kPackedKind), TypeConstraint(DataTypeSpecialized).setWantArrayKind())); }
pt geodesique(pt p, std::ostream *os = nullptr) const { std::set<pt> S; while (true) { if (!fits(vb::coo{p.xi(), p.yi()})) { break; } if (os != nullptr) { (*os) << p; } p.step(*this); if (S.count(p) != 0) { break; } S.insert(p); } if (os != nullptr) { (*os) << std::endl; } if (!fits(vb::coo{p.xi(), p.yi()})) { return pt(); } pt p_min = p; p.step(*this); while (p != p_min) { if (p < p_min) { p_min = p; } p.step(*this); } return p_min; }
bool Container::add_object(unique_ptr<Object> & o) { if (fits(o)) { weight_free -= o->get_weight(); weight += o->get_weight(); vol_free -= o->get_volume(); objects.push_back(move(o)); o = nullptr; return true; } else { return false; } }
TEST(Type, TypeConstraints) { EXPECT_TRUE(fits(Type::Gen, DataTypeGeneric)); EXPECT_FALSE(fits(Type::Gen, DataTypeCountness)); EXPECT_FALSE(fits(Type::Gen, DataTypeCountnessInit)); EXPECT_FALSE(fits(Type::Gen, DataTypeSpecific)); EXPECT_FALSE(fits(Type::Gen, DataTypeSpecialized)); EXPECT_TRUE(fits(Type::Cell, {DataTypeGeneric, DataTypeSpecific})); EXPECT_FALSE(fits(Type::Gen, {DataTypeGeneric, DataTypeSpecific})); }
void pl_collcontext_insert_object(pl_collisioncontext_t *ctxt, pl_recgrid_t *grid, pl_object_t *obj) { int octant = getoctant(&grid->centre, obj); if (grid->children[octant] && fits(grid->children[octant], obj)){ pl_collcontext_insert_object(ctxt, grid->children[octant], obj); } else { obj_array_push(&grid->objs, obj); } if (grid->objs.length > THRESHOLD) { split(ctxt, grid); } }
/***********************************************************************//** * @brief Save effective area into FITS file * * @param[in] filename FITS file. * @param[in] clobber Overwrite existing file?. * * This method saves the effective area information, and if available, the * efficiency factors, into the FITS response file. See the GLATAeff::write * method for details. ***************************************************************************/ void GLATAeff::save(const std::string& filename, const bool& clobber) { // Open FITS file GFits fits(filename, true); // Write effective area into file write(fits); // Close FITS file fits.save(clobber); // Return return; }
void plInsertObject(PLcollisioncontext *ctxt, PLrecgrid *grid, PLobject *obj) { int octant = getoctant(&grid->centre, obj); if (grid->children[octant] && fits(grid->children[octant], obj)){ plInsertObject(ctxt, grid->children[octant], obj); } else { obj_array_push(&grid->objs, obj); } if (grid->objs.length > THRESHOLD) { split(ctxt, grid); } }
/***********************************************************************//** * @brief Load LAT event cube from FITS file * * @param[in] filename FITS file name. ***************************************************************************/ void GLATEventCube::load(const GFilename& filename) { // Open FITS file GFits fits(filename); // Read event cube from FITS file read(fits); // Close FITS file fits.close(); // Return return; }
// Fill the pack with rects void CRectPacker::fill(int pack) { if (isPackValid(pack)) { for (int x = 0; x < mRects.size(); x++) { if (!mRects[x].packed) { if (fits(mRects[x],mPacks[pack])) { ++mNumPacked; split(pack,x); fill(mPacks[pack].children[0]); fill(mPacks[pack].children[1]); return; } } } } }
/***********************************************************************//** * @brief Load point spread function from performance table * * @param[in] filename Performance table file name. * * @exception GCTAExceptionHandler::file_open_error * File could not be opened for read access. * * This method loads the point spread function information from a PSF * response table. ***************************************************************************/ void GCTAPsf2D::load(const std::string& filename) { // Open PSF FITS file GFits fits(filename); // Read fits file read(fits); // Close PSF FITS file fits.close(); // Store filename m_filename = filename; // Return return; }
/***********************************************************************//** * @brief Load CTA event cube from FITS file * * @param[in] filename FITS filename. * * Loads the event cube from a FITS file. See the read() method for more * information about the structure of the FITS file. * * The method clears the object before loading, thus any events residing in * the object before loading will be lost. ***************************************************************************/ void GCTAEventCube::load(const GFilename& filename) { // Clear object clear(); // Open counts map FITS file GFits fits(filename); // Load counts map read(fits); // Close FITS file fits.close(); // Return return; }
/***********************************************************************//** * @brief Load exposure cube from FITS file * * @param[in] filename Performance table file name. * * Loads the exposure cube from a FITS file into the object. ***************************************************************************/ void GCTACubeExposure::load(const std::string& filename) { // Open FITS file GFits fits(filename); // Read PSF cube read(fits); // Close FITS file fits.close(); // Store filename m_filename = filename; // Return return; }
int main(int argc, const char *argv[]) { int num1, num2, maior, menor, val; printf("Insira um numero: \n"); scanf("%d", &num1); //insercao do primeiro numero printf("Insira um numero: \n"); scanf("%d", &num2); //insercao do segundo numero maior = big(num1, num2); //funcao para verificar o maior numero menor = small(num1, num2);//funcao para verificar o menor numero val = 0; while (maior >= menor) //condicao de parada { if (fits(maior,menor) == 1) //chamada da funcao "encaixa" val = 1; maior/=10; } if (val == 1) //se a funcao retornar "verdadeiro" o menor numero encaixa no maior { if(num1 > num2) { printf("%d é segmento de %d \n",num2, num1); } else { printf("%d é segmento de %d \n",num1, num2); } } else { if(num1 > num2) { printf("%d nao é segmento de %d \n",num2, num1); } else { printf("%d nao é segmento de %d \n",num1, num2); } } return 0; }
int main(int argc,char** argv) { ArgParser a(argc,argv); a.addArgument("InputFileName",ArgParser::required, "Name of the Input File"); a.addArgument("OutputFileName",ArgParser::required,"Name of the Output File"); a.addLongOption("lumi",ArgParser::reqArg,"specify luminosity (overrides value in workspace)"); std::string ret; if(a.process(ret) !=0){ std::cout << "Invalid Options: " << ret << std::endl; a.printOptions(argv[0]); return 0; } Fitter fits(a.getArgument("InputFileName").c_str(),a.getArgument("OutputFileName").c_str()); if(a.longFlagPres("lumi")) fits.setLumi( atof(a.getLongFlag("lumi").c_str()) ); fits.Run(); }
void process_minifeed_row (void) { char *p, *q; int len, i, c; struct lev_search_text_short_entry *LS; struct lev_search_text_long_entry *LL; if (!I[mf_id] || !fits(I[mf_user_id])) { return; } len = L[mf_text]; if (len > 8192) { return; } if (len < 256) { LS = write_alloc (21+len); LS->type = LEV_SEARCH_TEXT_SHORT + len; LS->rate = I[mf_created]; LS->rate2 = 0; LS->obj_id = ((long long) I[mf_id] << 32) + (unsigned) I[mf_user_id]; q = LS->text; } else { LL = write_alloc (23+len); LL->type = LEV_SEARCH_TEXT_LONG; LL->rate = I[mf_created]; LL->rate2 = 0; LL->obj_id = ((long long) I[mf_id] << 32) + (unsigned) I[mf_user_id]; LL->text_len = len; q = LL->text; } p = S[mf_text]; for (i = L[mf_text]; i > 0; i--) { c = (unsigned char) *p++; if (c < ' ') { c = ' '; } *q++ = c; } *q++ = 0; adj_rec++; }