int main(){ FILE *out; int start=1001; int end=2000; int x; int y; out=fopen("1001-2000(conj).csv", "w+"); for(x=start;x<=end;x++){ for(y=1;y<=phi(x);y++){ if(y==phi(x)){ fprintf(out,"%d,%d,%d\n\n",x,y,character(x,y)); } else{ fprintf(out,"%d,%d,%d\n",x,y,character(x,y)); } } } fclose(out); }
TrieNode* TrieDictionary::find_node_for_radix(const std::string& radix) const noexcept { TrieNode* current_node = root.get(); for (const char c_character : radix) { std::string character(1, c_character); if (!current_node->contains_character(character)) { return nullptr; } else { current_node = current_node->get_child_for_character(character); } } return current_node; }
closure *parse_number(FILE *file, closure *accum) { wchar_t c = fgetwc(file); if(iswdigit(c)){ return parse_number(file, cons(character(c), accum)); } else if(iswspace(c)) { return string_to_number(reverse(accum)); } else if(c == L')') { ungetwc(c, file); return string_to_number(reverse(accum)); } else { ungetwc(c, file); return parse_symbol(file, accum); } }
void renter_combat( char_data* ch ) { char_data* rch; for( int i = 0; i < *ch->array; i++ ) { if( ( rch = character( ch->array->list[i] ) ) == NULL || rch == ch ) continue; if( is_aggressive( ch, rch ) ) ch->aggressive += rch; } init_attack( ch ); }
int st(struct parser* p) { if (!identifier(p)) { return 0; } label(p->id); character(p, '='); ex1(p); lstring(p, ".,"); out1("R"); return 1; }
int main(void) { int option, exit_code; clrscr(); //clear screen to start program printf("This program will convert input characters\n"); printf("into an ASCII version of braille."); do{ printf("\nWould you like to type in (C)haracters, import a (F)ile, or (Q)uit? [C/F/Q] "); option = getch(); //get input one char at a time option = toupper(option); //convert to upper case to simplify code printf("%c\n", option); //echo input switch (option) { case 'C' : //case for keyboard entry { /*charout = */character(); // printf("%x hex entered.\n", charout); //debuging tool break; } case 'F' : //case for file entry { exit_code = file(); if(exit_code == 1) printf("\n"); // printf("Would you like to try again? "); break; } case 'Q': //case for quiting { printf("Program terminated.\n"); break; } default: //if all else fails { printf("I couldn't read your answer, please try again.\n\n"); } } } while(option != 'Q'); //the end of a do{} - while() loop return 0; }
int send(struct array *word) { sem_wait( &(shared->sem_reader) ); strcpy(shared->buffer1[bufferPtr], word->word); sem_post( &(shared->sem_textformater) ); bufferPtr = (bufferPtr+1) % CELLS ; if( character(word->word[0])==TRUE ) { int random = rand() % period; printf("Reader: Just wrote word: %s\nSleep for %d micro sec\n\n", word->word, random); usleep( random ); } return TRUE; }
void tex::append_italic_correction () { ptr p; fnt f; if (tail != head) { if (is_char_node(tail)) p = tail; else if (type(tail) == LIGATURE_NODE) p = lig_char(tail); else return; f = font(p); tail = link(tail) = new_kern(char_italic(f, char_info(f, character(p)))); subtype(tail) = EXPLICIT; } }
void LazyJSValue::dumpInContext(PrintStream& out, DumpContext* context) const { switch (m_kind) { case KnownValue: value().dumpInContext(out, context); return; case SingleCharacterString: out.print("Lazy:SingleCharacterString("); out.printf("%04X", static_cast<unsigned>(character())); out.print(" / ", StringImpl::utf8ForCharacters(&u.character, 1), ")"); return; case KnownStringImpl: out.print("Lazy:String(", stringImpl(), ")"); return; } RELEASE_ASSERT_NOT_REACHED(); }
void short_display_n(int p,int m) { int i= 0; font_in_short_display= null_font; if(p==null) return; while(p!=null){ if(is_char_node(p)){ if(p<=max_halfword){ if(font(p)!=font_in_short_display){ if(!is_valid_font(font(p))) print_char('*'); else print_font_identifier(font(p)); print_char(' '); font_in_short_display= font(p); } print(character(p)); } }else{ if((type(p)==glue_node)|| (type(p)==disc_node)|| (type(p)==penalty_node)|| ((type(p)==kern_node)&&(subtype(p)==explicit_kern|| subtype(p)==italic_kern))){ incr(i); } if(i>=m) return; if(type(p)==disc_node){ print_char('|'); short_display(vlink(pre_break(p))); print_char('|'); short_display(vlink(post_break(p))); print_char('|'); }else{ print_short_node_contents(p); } } p= vlink(p); if(p==null) return; } update_terminal(); }
QPixmap PixmapCache::text(const QString &string) { QPixmap pixmap; if (!QPixmapCache::find(string, &pixmap)) { pixmap = QPixmap(string.size() * 64, 64); pixmap.fill(Qt::transparent); { QPainter painter(&pixmap); for(int i = 0; i < string.size(); ++i) { painter.drawPixmap(i * 64, 0, 64, 64, character(string.at(i))); } } QPixmapCache::insert(string, pixmap); } return pixmap; }
TEST(TestCharacterSerializer, TestSaveAndLoad){ // Create the new Character Character character("Random", 19, SkillType::Dragon); // Save the Character to disk CharacterSerializer::GetInstance().SaveCharacter(character); // Load the Character ASSERT_TRUE(CharacterSerializer::GetInstance().Character("Random")); // Check for match Character *loadedCharacter= CharacterSerializer::GetInstance().GetPlayer(); EXPECT_EQ(character.GetName(), loadedCharacter->GetName()); EXPECT_EQ(character.GetLevel(), loadedCharacter->GetLevel()); EXPECT_EQ(character.GetSkill().GetSkillType(), loadedCharacter->GetSkill().GetSkillType()); std::remove("Random.dat"); // Removing the saved character }
SpreadSheet::SpreadSheet(int rows, int cols, QWidget *parent) : QMainWindow(parent) { addToolBar(toolBar = new QToolBar()); formulaInput = new QLineEdit(); cellLabel = new QLabel(toolBar); cellLabel->setMinimumSize(80, 0); toolBar->addWidget(cellLabel); toolBar->addWidget(formulaInput); table = new QTableWidget(rows, cols, this); table->setSizeAdjustPolicy(QTableWidget::AdjustToContents); for (int c = 0; c < cols; ++c) { QString character(QChar('A' + c)); table->setHorizontalHeaderItem(c, new QTableWidgetItem(character)); } table->setItemPrototype(table->item(rows - 1, cols - 1)); table->setItemDelegate(new SpreadSheetDelegate()); createActions(); updateColor(0); setupMenuBar(); setupContents(); setupContextMenu(); setCentralWidget(table); statusBar(); connect(table, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), this, SLOT(updateStatus(QTableWidgetItem*))); connect(table, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), this, SLOT(updateColor(QTableWidgetItem*))); connect(table, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), this, SLOT(updateLineEdit(QTableWidgetItem*))); connect(table, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(updateStatus(QTableWidgetItem*))); connect(formulaInput, SIGNAL(returnPressed()), this, SLOT(returnPressed())); connect(table, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(updateLineEdit(QTableWidgetItem*))); setWindowTitle(tr("Spreadsheet")); }
void TrieDictionary::add_word(const std::string& word) { if (!is_word_allowed(word)) { return; } TrieNode* current_node = root.get(); for (const char c_character : word) { std::string character(1, c_character); if (!current_node->contains_character(character)) { current_node->add_child_for_character(character); } current_node = current_node->get_child_for_character(character); } current_node->mark_as_word(); }
bool nano::uint256_union::decode_account (std::string const & source_a) { auto error (source_a.size () < 5); if (!error) { auto xrb_prefix (source_a[0] == 'x' && source_a[1] == 'r' && source_a[2] == 'b' && (source_a[3] == '_' || source_a[3] == '-')); auto nano_prefix (source_a[0] == 'n' && source_a[1] == 'a' && source_a[2] == 'n' && source_a[3] == 'o' && (source_a[4] == '_' || source_a[4] == '-')); error = (xrb_prefix && source_a.size () != 64) || (nano_prefix && source_a.size () != 65); if (!error) { if (xrb_prefix || nano_prefix) { auto i (source_a.begin () + (xrb_prefix ? 4 : 5)); if (*i == '1' || *i == '3') { nano::uint512_t number_l; for (auto j (source_a.end ()); !error && i != j; ++i) { uint8_t character (*i); error = character < 0x30 || character >= 0x80; if (!error) { uint8_t byte (account_decode (character)); error = byte == '~'; if (!error) { number_l <<= 5; number_l += byte; } } } if (!error) { *this = (number_l >> 40).convert_to<nano::uint256_t> (); uint64_t check (number_l & static_cast<uint64_t> (0xffffffffff)); uint64_t validation (0); blake2b_state hash; blake2b_init (&hash, 5); blake2b_update (&hash, bytes.data (), bytes.size ()); blake2b_final (&hash, reinterpret_cast<uint8_t *> (&validation), 5); error = check != validation; } }
void Font::addCharacter(const unsigned char letter, unsigned int x, unsigned int y, const vec2 &offset, bool cutSpaces){ vec2 min = vec2(float(x*partSize), float(y*partSize)); vec2 max = vec2(float(x*partSize+partSize), float(y*partSize+partSize)); vec2 size = vec2(float(texture->width()), float(texture->height())); if(cutSpaces && texture && texture->data.size() && texture->getBytesPerPixel() == 4){ unsigned char* data = &texture->data[0]; float width = float(texture->width()); min = max; max = vec2(float(x*partSize), float(y*partSize)); for(float ty = float(y*partSize); ty < float(y*partSize+partSize); ty++){ for(float tx = float(x*partSize); tx < float(x*partSize+partSize); tx++){ unsigned int i = ty*width*4.0f+tx*4.0f+3; if(int(data[i]) >= 100){ if(tx < min.x){ min.x = tx; } else if(tx > max.x){ max.x = tx; } if(ty < min.y){ min.y = ty; } else if(ty > max.y){ max.y = ty; } } } } } min -= padding; max += padding; letters[letter] = character(); letters[letter].min = (min)/size; letters[letter].max = (max)/size; letters[letter].size = (max-min)/float(partSize); letters[letter].offset = offset; }
int main() { #ifndef NDEBUG Test(); #endif Character character(100,100,100,Item::shield); int chapter = 1; const bool auto_play{false}; const Language language = Language::Dutch; while (1) { std::cout << std::string(60,'-') << '\n'; std::cout << chapter << '\n'; std::cout << std::string(60,'-') << '\n'; DoChapter(chapter,character,language,auto_play); if (chapter == 0) break; } }
int TextDisplay::_putc(int value) { if(value == '\n') { _column = 0; _row++; if(_row >= rows()) { _row = 0; } } else { character(_column, _row, value); _column++; if(_column >= columns()) { _column = 0; _row++; if(_row >= rows()) { _row = 0; } } } return value; }
/* * Escape handler -- * called on recognition of ``escapec'' at the beginning of a line */ int escape(void) { char gch; esctable_t *p; char c = character(value(ESCAPE)); gch = (getchar()&STRIP_PAR); for (p = etable; p->e_char; p++) if (p->e_char == gch) { if ((p->e_flags&PRIV) && uid) continue; (void)printf("%s", ctrl(c)); (*p->e_func)(gch); return (0); } /* ESCAPE ESCAPE forces ESCAPE */ if (c != gch) xpwrite(FD, &c, 1); return (gch); }
void react_attack( char_data* ch, char_data* victim ) { char_data* rch; if( victim->leader == ch ) stop_follower( victim ); if( ch->leader == victim ) stop_follower( ch ); init_attack( victim, ch ); for( int i = 0; i < *ch->array; i++ ) { if( ( rch = character( ch->array->list[i] ) ) != NULL ) { if( join_fight( victim, ch, rch ) ) init_attack( rch, ch ); else if( join_fight( ch, victim, rch ) ) init_attack( rch, victim ); } } }
void QCustomTableWidget::addCharacter(int index) { if (index < 0) { // if no row is selected, we insert it at the end index += rowCount(); } if(pChangeCharacterDial->exec()==QDialog::Accepted) { // updating the CharacterList if (pCharacters) { Character character(pChangeCharacterDial->name().toStdString(), pChangeCharacterDial->shortDescription().toStdString()); pCharacters->add(character,index+1); emit modificationDone(new CharacterModification(pCharacters, new Character(character), index+1, true)); } // updating the display int column_nb = columnCount(); // created cells iCreatedCells = column_nb; insertRow(index+1); for (int i = 0; i < column_nb; i++) { QTableWidgetItem *row1 = new QTableWidgetItem("0"); setItem(index+1,i,row1); } QTableWidgetItem *rowHeaderItem = verticalHeaderItem(index+1); if (rowHeaderItem) { rowHeaderItem->setText(headerText(pChangeCharacterDial->name(), pChangeCharacterDial->shortDescription())); } else { rowHeaderItem = new QTableWidgetItem(headerText(pChangeCharacterDial->name(), pChangeCharacterDial->shortDescription())); setVerticalHeaderItem(index+1, rowHeaderItem); } scrollTo(index+1, -1); } }
void NewGameMenuController::createCharacter(std::string name) { //We generate the starting map Map map = MapGenerator::generate(40,40, new Dungeon(), "1_1_1", 5); //And random coordinates int x, y; do { x = rand()%map.getLength(); y = rand()%map.getWidth(); } while (map.cell[x][y].isSolid()); //We create the character Character character(name, HUMAN_CODE, "1_1_1"); character.setX(x); character.setY(y); Interface interface; //And we save the map and the character SaveUtils::save(character, interface); std::string s = "/"+StringUtils::saveStem(name); s = WORLD_PATH + s; boost::filesystem::path path(s); boost::filesystem::create_directory(path); SaveUtils::saveMap(character.getName(), character.getMap(), map); }
std::vector<LevelData> initializeLevelData() { std::vector<LevelData> data(TileMapNode::TypeCount); data[TileMapNode::Rabbits].firstLayer = firstLayer; data[TileMapNode::Rabbits].secondLayer = secondLayer; data[TileMapNode::Rabbits].collisions = collisions; data[TileMapNode::Rabbits].tileSize = sf::Vector2u(32, 32); data[TileMapNode::Rabbits].levelSize = sf::Vector2f(32, 18); data[TileMapNode::Rabbits].texture = Textures::Tileset; std::function<void(TileMapNode*, const TextureHolder&, const FontHolder&)> element = [](TileMapNode* map, const TextureHolder& mTextures, const FontHolder& fonts) { std::unique_ptr<Character> character(new Character(Character::Neutral, mTextures, fonts, map)); character->setPosition(390, 328); map->attachChild(std::move(character)); }; data[TileMapNode::Rabbits].elements.push_back(element); return data; }
/* * Escape handler -- * called on recognition of ``escapec'' at the beginning of a line */ static int escape(void) { int gch; esctable_t *p; char c = character(value(ESCAPE)); gch = (getchar()&STRIP_PAR); /* XXX does not check for EOF */ for (p = etable; p->e_char; p++) if (p->e_char == gch) { if ((p->e_flags&PRIV) && uid) continue; printf("%s", ctrl(c)); (*p->e_func)(gch); return (0); } /* ESCAPE ESCAPE forces ESCAPE */ if (c != gch) parwrite(FD, &c, 1); return (gch); }
closure *parse_symbol(FILE *file, closure *accum) { //printf("parse sym\n"); wchar_t c = fgetwc(file); if(iswspace(c)) { return string_to_symbol(reverse(accum)); } else if(c == L'\"'){ ungetwc(c, file); return string_to_symbol(reverse(accum)); } else if(c == L'('){ ungetwc(c, file); return string_to_symbol(reverse(accum)); } else if(c == L')') { ungetwc(c, file); return string_to_symbol(reverse(accum)); } else if(c == L'#'){ ungetwc(c, file); return string_to_symbol(reverse(accum)); } else { return parse_symbol(file, cons(character(c), accum)); } }
/*ARGSUSED*/ void listvariables(int c) { value_t *p; char *buf; char charbuf[5]; /* for vis(3), 4 chars for encoding, plus nul */ puts("v\r"); for (p = vtable; p->v_name; p++) { fputs(p->v_name, stdout); switch (p->v_type&TMASK) { case STRING: if (p->v_value) { buf = malloc(4*strlen(p->v_value) + 1); if (buf == NULL) { fprintf(stderr, "Unable to malloc()\n"); abort(); } strvis(buf, p->v_value, VIS_WHITE); printf(" %s", buf); free(buf); } putchar('\r'); putchar('\n'); break; case NUMBER: printf(" %ld\r\n", number(p->v_value)); break; case BOOL: printf(" %s\r\n", !boolean(p->v_value) ? "false" : "true"); break; case CHAR: vis(charbuf, character(p->v_value), VIS_WHITE, 0); printf(" %s\r\n", charbuf); break; } } }
bool Parser::number(std::string::iterator &iter, double& val) { auto localIter = iter; double localValue = 0; // A single digit int dgt = 0; // If next char is a digit or it was a decimal point previously then try to list all digits/decimal points if (digit(localIter) || isDecimalPoint(localIter)) { double floatVal = 0; // While finding digits or decimal points while (digit(localIter) || isDecimalPoint(localIter)) { if (character(localIter, '.')) { if (!floating(localIter, floatVal)) throw std::exception("Syntax error"); } else { // Convert every digit to number and then add to the value dgt = (*localIter) - '0'; localValue = localValue * 10 + dgt; localIter++; } } // If found all the digits set factor's value and iter to the local localValue = localValue + floatVal; iter = localIter; val = localValue; return true; } return false; }
void Obj_Data :: To( content_array* where ) { event_data* event; room_data* room; char_data* ch; obj_data* obj; int i; if( array != NULL ) { roach( "Adding object somewhere which isn't nowhere." ); roach( "-- Obj = %s", this ); From( number ); } if( ( room = Room( where->where ) ) != NULL ) { if( pIndexData->item_type == ITEM_CORPSE && value[0] > 0 ) { event = new event_data( execute_decay, this ); add_queue( event, value[0] ); } } if( ( ch = character( where->where ) ) != NULL && where == &ch->wearing ) { equip( ch, this ); for( i = 0; i < ch->wearing; i++ ) { obj = (obj_data*) ch->wearing[i]; if( obj->position > position || ( obj->position == position && obj->layer > layer ) ) break; } insert( *where, this, i ); array = where; } Thing_Data :: To( where ); }
/*VARARGS1*/ static void vassign(value_t *p, char *v) { if (!vaccess(p->v_access, WRITE)) { printf("access denied\r\n"); return; } switch (p->v_type&TMASK) { case STRING: if (p->v_value && equal(p->v_value, v)) return; if (!(p->v_type&(ENVIRON|INIT))) free(p->v_value); if ((p->v_value = strdup(v)) == NOSTR) { printf("out of core\r\n"); return; } p->v_type &= ~(ENVIRON|INIT); break; case NUMBER: if (number(p->v_value) == number(v)) return; setnumber(p->v_value, number(v)); break; case BOOL: if (boolean(p->v_value) == (*v != '!')) return; setboolean(p->v_value, (*v != '!')); break; case CHAR: if (character(p->v_value) == *v) return; setcharacter(p->v_value, *v); } p->v_access |= CHANGED; }
void short_display(int p) { while(p!=null){ if(is_char_node(p)){ if(lig_ptr(p)!=null){ short_display(lig_ptr(p)); }else{ if(font(p)!=font_in_short_display){ if(!is_valid_font(font(p))) print_char('*'); else print_font_identifier(font(p)); print_char(' '); font_in_short_display= font(p); } print(character(p)); } }else{ print_short_node_contents(p); } p= vlink(p); } }