void Binary(int n) { if (n<1) { printf("%s\n",A); return; } A[n-1]='a'; Binary(n-1); A[n-1]='b'; Binary(n-1); }
void PerformanceStackPair::AddValue(uint32_t i, UpdateBuilder& builder) { const uint16_t index = i % NUM_POINTS_PER_TYPE; switch (i % 7) { case (0): builder.Update(Binary(i % 2 == 0), index, EventMode::Force); break; case (1): builder.Update(DoubleBitBinary(i % 2 == 0 ? DoubleBit::DETERMINED_ON : DoubleBit::DETERMINED_OFF), index, EventMode::Force); break; case (2): builder.Update(Analog(i), index, EventMode::Force); break; case (3): builder.Update(Counter(i), index, EventMode::Force); break; case (4): builder.Update(FrozenCounter(i), index, EventMode::Force); break; case (5): builder.Update(BinaryOutputStatus(i % 2 == 0), index, EventMode::Force); break; default: builder.Update(AnalogOutputStatus(i), index, EventMode::Force); break; } }
int main() { int n; scanf("%d",&n); Binary(n); }
void TG2KS(unsigned char *c1, unsigned char *c2) { unsigned int index, code ; code = (*c1 << 8) | *c2 ; if ((index = Binary(code, MAX_KSCODE)) != MAX_KSCODE) { *c1 = (index / 94) + 0xb0 ; *c2 = (index % 94) + 0xa1 ; } else { *c1 = *c2 = SPACE ; for (index = 0; index < SINGLENUM; index++) { if (SGtbl[index] == code) { *c1 = 0xa4 ; *c2 = 0xa1 + index ; break ; } } } }
Node* GenCommaExpr(void) { if (CanDo(',')) { Node* left = GenCommaExpr(); Node* right = GenAssignExpr(); return Binary(',', left, right); } return GenAssignExpr(); }
Node* GenAssignExpr(void) { if (CanDo('=')) { Node* left = GenLvalExpr(); Node* right = GenAssignExpr(); return Binary('=', left, right); } return GenCondExpr(); }
Node* GenAddExpr(void) { if (CanDo('-')) { Node* left = GenAddExpr(); Node* right = GenMulExpr(); return Binary('-', left, right); } return GenMulExpr(); }
Node* GenMulExpr(void) { if (CanDo('*')) { Node* left = GenMulExpr(); Node* right = GenLvalExpr(); // Skip cast-expr all the way to unary-expr return Binary('*', left, right); } return GenLvalExpr(); // Skip cast-expr all the way to unary-expr }
void BinOp( TYPE typ1, TYPE typ2, OPTR opr ) { //=============================================== // Generate code to perform a binary operation. if( typ1 != FT_NO_TYPE ) { // binary operator Binary( typ1, typ2, opr ); } else { // unary operator. Unary( typ2, opr ); } }
TEST(LoadNodeTest, Binary) { Node node = Load( "[!!binary \"SGVsbG8sIFdvcmxkIQ==\", !!binary " "\"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS" "B0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIG" "x1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbi" "B0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZG" "dlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS" "4K\"]"); EXPECT_EQ(Binary(reinterpret_cast<const unsigned char*>("Hello, World!"), 13), node[0].as<Binary>()); EXPECT_EQ(Binary(reinterpret_cast<const unsigned char*>( "Man is distinguished, not only by his reason, " "but by this singular passion from other " "animals, which is a lust of the mind, that by " "a perseverance of delight in the continued and " "indefatigable generation of knowledge, exceeds " "the short vehemence of any carnal pleasure.\n"), 270), node[1].as<Binary>()); }
void PrintPosFlags(Position *p, int len, int count) { char yes[2] = {'n', 'y'}, side[2] = {'W', 'B'}; printf("\nW: [K %c%d] [KC %c] [QC %c] [EP %c%c%c%c%c%c%c%c]\n", 'a'+p->wkingx-2, p->wkingy-1, yes[Binary(p->castle & WKC)], yes[Binary(p->castle & WQC)], yes[IsEpSquare(2,5,p->epstatus)], yes[IsEpSquare(3,5, p->epstatus)], yes[IsEpSquare(4,5,p->epstatus)], yes[IsEpSquare(5,5, p->epstatus)], yes[IsEpSquare(6,5,p->epstatus)], yes[IsEpSquare(7,5, p->epstatus)], yes[IsEpSquare(8,5,p->epstatus)], yes[IsEpSquare(9,5, p->epstatus)] ); printf("B: [K %c%d] [KC %c] [QC %c] [EP %c%c%c%c%c%c%c%c]\n", 'a'+p->bkingx-2, p->bkingy-1, yes[Binary(p->castle & BKC)], yes[Binary(p->castle & BQC)], yes[IsEpSquare(2,6,p->epstatus)], yes[IsEpSquare(3,6, p->epstatus)], yes[IsEpSquare(4,6,p->epstatus)], yes[IsEpSquare(5,6, p->epstatus)], yes[IsEpSquare(6,6,p->epstatus)], yes[IsEpSquare(7,6, p->epstatus)], yes[IsEpSquare(8,6,p->epstatus)], yes[IsEpSquare(9,6, p->epstatus)] ); printf("Side to move: %c Length of Series: %d Count in Series: %d\n", side[Binary(p->side & BLACK)], len, count); }
int main() { int i; int j; int n; while(scanf("%d",&n)==1) { if(!n) break; Binary(n); printf("The parity of %s is %d (mod 2).\n",a,NumberOfOnes()); } return 0; }
size_t operator()(const TVector& v) const { // taken from http://www.beosil.com/download/CollisionDetectionHashing_VMV03.pdf static std::array<size_t, 3> magicNumbers{73856093, 19349663, 83492791}; union Binary { double d; unsigned long ul; }; size_t vectorHash = 0; for (int i = 0; i < v.size(); ++i) vectorHash ^= magicNumbers[i] * Binary({v[i]}).ul; return vectorHash; }
Value Object_interp::ConvFromTclObj(Environment &env, Signal &sig, Tcl_Obj *objPtr) { Tcl_ObjType *typePtr = objPtr->typePtr; if (typePtr == nullptr) { return Value(objPtr->bytes, objPtr->length); } else if (typePtr == ObjType_boolean) { int value; ::Tcl_GetBooleanFromObj(_interp, objPtr, &value); return Value(value? true : false); } else if (typePtr == ObjType_bytearray) { int length; unsigned char *binary = ::Tcl_GetByteArrayFromObj(objPtr, &length); return Value(new Object_binary(env, Binary(reinterpret_cast<char *>(binary), length), true)); } else if (typePtr == ObjType_double) { double value; ::Tcl_GetDoubleFromObj(_interp, objPtr, &value); return Value(value); } else if (typePtr == ObjType_int) { int value; ::Tcl_GetIntFromObj(_interp, objPtr, &value); return Value(value); } else if (typePtr == ObjType_list) { int length; ::Tcl_ListObjLength(_interp, objPtr, &length); Value result; Object_list *pObjList = result.InitAsList(env); pObjList->Reserve(length); for (int i = 0; i < length; i++) { Tcl_Obj *objElemPtr; ::Tcl_ListObjIndex(_interp, objPtr, i, &objElemPtr); pObjList->Add(ConvFromTclObj(env, sig, objElemPtr)); if (sig.IsSignalled()) return Value::Nil; } return result; } else if (typePtr == ObjType_string) { int length; char *value = ::Tcl_GetStringFromObj(objPtr, &length); return Value(value); } return Value(objPtr->bytes, objPtr->length); }
/// <summary> /// демонстрация бинарного поиска /// </summary> void Sol3() { // массив заполним от 0 до N-1 int a[MaxN]; for (int i = 0; i < MaxN; i++) { a[i] = i; } printf("Введите число для поиска, массив заполнен числами от 0 до %d\n",MaxN); int variant = 0; scanf("%i", &variant); variant = Binary(MaxN,a,variant); if (variant == -1) { printf("\nЗначение не найдено!"); } else { printf("\nЗначение найдено на позиции %d массива",variant); } }
TermFactory::TermFactory() : ConstructionFactory<Term*>("Term") { registerConstructor("", fl::null); registerConstructor(Bell().className(), &(Bell::constructor)); registerConstructor(Binary().className(), &(Binary::constructor)); registerConstructor(Concave().className(), &(Concave::constructor)); registerConstructor(Constant().className(), &(Constant::constructor)); registerConstructor(Cosine().className(), &(Cosine::constructor)); registerConstructor(Discrete().className(), &(Discrete::constructor)); registerConstructor(Function().className(), &(Function::constructor)); registerConstructor(Gaussian().className(), &(Gaussian::constructor)); registerConstructor(GaussianProduct().className(), &(GaussianProduct::constructor)); registerConstructor(Linear().className(), &(Linear::constructor)); registerConstructor(PiShape().className(), &(PiShape::constructor)); registerConstructor(Ramp().className(), &(Ramp::constructor)); registerConstructor(Rectangle().className(), &(Rectangle::constructor)); registerConstructor(SShape().className(), &(SShape::constructor)); registerConstructor(Sigmoid().className(), &(Sigmoid::constructor)); registerConstructor(SigmoidDifference().className(), &(SigmoidDifference::constructor)); registerConstructor(SigmoidProduct().className(), &(SigmoidProduct::constructor)); registerConstructor(Spike().className(), &(Spike::constructor)); registerConstructor(Trapezoid().className(), &(Trapezoid::constructor)); registerConstructor(Triangle().className(), &(Triangle::constructor)); registerConstructor(ZShape().className(), &(ZShape::constructor)); }
void setHeader(RPG2kString const& header) { seekFromSet(); set( Binary(header) ); }
DrFinestra::DrFinestra(QWidget *parent,const char *name) :QWidget(parent,name){ // esci QPushButton *esci = new QPushButton("&Esci",this,"Esci"); esci->setFont( QFont("Times",18,QFont::Bold) ); connect(esci, SIGNAL(clicked()), qApp,SLOT(quit()) ); e1 = new ElementiGrafici(this); // disegna linee QCheckBox *linee = new QCheckBox("&Linee",this,"linee"); linee->toggle(); connect(linee,SIGNAL(clicked() ),e1,SLOT(DisegnaLinee()) ); // disegna punti QCheckBox *punti = new QCheckBox("&Punti",this,"punti"); connect(punti,SIGNAL(clicked() ),e1,SLOT(DisegnaPunti()) ); // distr QPushButton *distr = new QPushButton("&Distr",this,"distr"); connect(distr, SIGNAL(clicked() ), e1,SLOT(PuntiDistribuzione()) ); // Valori QSpinBox *Valori = new QSpinBox(2,1000,20,this,"Valori"); connect(Valori,SIGNAL(valueChanged(int)),e1,SLOT(ImpValori(int)) ); connect(e1,SIGNAL(ValoriCambiati(int)),Valori,SLOT(setValue(int)) ); // disegna griglia QCheckBox *griglia = new QCheckBox("&Griglia",this,"griglia"); connect(griglia,SIGNAL(clicked() ),e1,SLOT(DisegnaGriglia()) ); // seRiscala QCheckBox *riscala = new QCheckBox("&Ris",this,"riscala"); connect(riscala,SIGNAL(clicked() ),e1,SLOT(SeRiscala()) ); // seRisTutto QCheckBox *risTutto = new QCheckBox("&Tutti",this,"risTutto"); connect(risTutto,SIGNAL(clicked() ),e1,SLOT(SeRiscalaTutto()) ); // seSet QCheckBox *nset = new QCheckBox("&Set",this,"nset"); connect(nset,SIGNAL(clicked() ),e1,SLOT(NSet()) ); // salva QPushButton *salva = new QPushButton("&Salva",this,"autocor"); connect(salva, SIGNAL(clicked() ), e1,SLOT(Salva()) ); // Animazione a1 = new Animation(this); connect(a1, SIGNAL(PuntaCoord(double **,int,int,int) ), e1,SLOT(ApriExt(double**,int,int,int)) ); //connect(a1, SIGNAL( PuntaCoord(Variabili *v1) ), e1,SLOT(ApriExt(Variabili *v1)) ); // image QPushButton *image = new QPushButton("&Image",this,"image"); connect(image, SIGNAL(clicked() ), a1,SLOT(Open()) ); // punta QPushButton *punta = new QPushButton("&Punta",this,"Punta"); connect(punta, SIGNAL(clicked() ), a1,SLOT(Punta()) ); // nomeFile QLineEdit *nomeFile = new QLineEdit(this,"nomeFile"); connect(nomeFile,SIGNAL( textChanged(const QString &)),a1,SLOT( NomeFile(const QString &)) ); // filter QPushButton *filter = new QPushButton("&Filter",this,"filter"); connect(filter, SIGNAL(clicked() ), a1,SLOT(Filter()) ); // motion QPushButton *motion = new QPushButton("&Motion",this,"motion"); connect(motion, SIGNAL(clicked() ), a1,SLOT(Motion()) ); // run QPushButton *run = new QPushButton("&run",this,"run"); connect(run, SIGNAL(clicked() ), a1,SLOT(Run()) ); // filterMC QPushButton *filterMC = new QPushButton("&MC",this,"MC"); connect(filterMC, SIGNAL(clicked() ), a1,SLOT(FilterMC()) ); // filterCoarseGrain QPushButton *filterCoarseGrain = new QPushButton("&CG",this,"CG"); connect(filterCoarseGrain, SIGNAL(clicked() ), a1,SLOT(FilterCoarseGrain()) ); connect(filterCoarseGrain, SIGNAL(clicked() ), e1,SLOT(repaint()) ); // NGrana QSpinBox *NGrana = new QSpinBox(0,5,1,this,"NGrana"); connect(NGrana,SIGNAL(valueChanged(int)),a1,SLOT(ImpGrana(int)) ); // filterIncrease QPushButton *filterIncrease = new QPushButton("&Increase",this,"Increase"); connect(filterIncrease, SIGNAL(clicked() ), a1,SLOT(FilterIncrease()) ); // filterContrast QPushButton *filterContrast = new QPushButton("&Contrast",this,"Contrast"); connect(filterContrast, SIGNAL(clicked() ), a1,SLOT(FilterContrast()) ); connect(filterContrast, SIGNAL(clicked() ), e1,SLOT(repaint()) ); // BW QPushButton *blackwhite = new QPushButton("&B/W",this,"B/W"); connect(blackwhite, SIGNAL(clicked() ), a1,SLOT(BlackWhite()) ); connect(blackwhite, SIGNAL(clicked() ), e1,SLOT(repaint()) ); // binary QPushButton *binary = new QPushButton("&0/1",this,"0/1"); connect(binary, SIGNAL(clicked() ), a1,SLOT(Binary()) ); connect(binary, SIGNAL(clicked() ), e1,SLOT(repaint()) ); // Histo QPushButton *histo = new QPushButton("&Histo",this,"Histo"); connect(histo, SIGNAL(clicked() ), a1,SLOT(Histo()) ); // NablaPhi QPushButton *nablaphi = new QPushButton("&Phi",this,"Phi"); connect(nablaphi, SIGNAL(clicked() ), a1,SLOT(NablaPhi()) ); connect(nablaphi, SIGNAL(clicked() ), e1,SLOT(repaint()) ); // Script s1 = new DrScript(); // > QPushButton *forward = new QPushButton("&>",this,">"); connect(forward, SIGNAL(clicked() ), a1,SLOT(IncrSlide()) ); connect(forward, SIGNAL(clicked() ), s1,SLOT(IncrSlide()) ); // Scena QGridLayout *grid= new QGridLayout(this,1,3,10); //grid->addWidget(a1,1,1); grid->setColStretch(1,15); grid->setColStretch(0,2); grid->setColStretch(2,1); grid->setRowStretch(1,5); grid->setRowStretch(0,0); grid->setRowStretch(2,2); grid->setRowMinimumHeight(1,200); grid->setRowStretch(2,0); grid->setRowStretch(3,0); QVBoxLayout *PicHisto = new QVBoxLayout; grid->addLayout(PicHisto,1,1); PicHisto->addWidget(e1); PicHisto->addWidget(a1); a1->setMinimumHeight(height()); QHBoxLayout *Disegna = new QHBoxLayout; QVBoxLayout *DisegnaSx = new QVBoxLayout; QVBoxLayout *DisegnaDx = new QVBoxLayout; // Disegna->addWidget(cosaDisegna); DisegnaSx->addWidget(linee); DisegnaSx->addSpacing(-10); DisegnaSx->addWidget(punti); DisegnaSx->addSpacing(-10); DisegnaSx->addWidget(griglia); DisegnaSx->addSpacing(-10); DisegnaDx->addWidget(riscala); DisegnaDx->addSpacing(-10); DisegnaDx->addWidget(risTutto); DisegnaDx->addSpacing(-10); DisegnaDx->addWidget(nset); Disegna->addLayout(DisegnaSx); Disegna->addLayout(DisegnaDx); //QHBoxLayout *Coordinate = new QHBoxLayout; QVBoxLayout *ASinistra = new QVBoxLayout; grid->addLayout(ASinistra,1,0); ASinistra->addLayout(Disegna); ASinistra->addWidget(distr); ASinistra->addWidget(Valori); ASinistra->addWidget(s1); ASinistra->addWidget(salva); //grid->addWidget(s1,2,0); QVBoxLayout *ASinistraGiu = new QVBoxLayout; grid->addLayout(ASinistraGiu,2,0); QHBoxLayout *InAlto = new QHBoxLayout; grid->addLayout(InAlto,0,1); InAlto->addWidget(histo); InAlto->addWidget(blackwhite); InAlto->addWidget(binary); InAlto->addWidget(nablaphi); InAlto->addWidget(forward); InAlto->addWidget(punta); QVBoxLayout *InAlto2 = new QVBoxLayout; grid->addLayout(InAlto2,0,2); QVBoxLayout *ADestra = new QVBoxLayout; grid->addLayout(ADestra,1,2); ADestra->addWidget(esci); ADestra->addWidget(image); ADestra->addWidget(nomeFile); ADestra->addWidget(filter); ADestra->addWidget(motion); ADestra->addWidget(run); ADestra->addWidget(filterMC); ADestra->addWidget(NGrana); ADestra->addWidget(filterCoarseGrain); ADestra->addWidget(filterIncrease); ADestra->addWidget(filterContrast); ADestra->setSpacing(0); QVBoxLayout *ADestra1 = new QVBoxLayout; grid->addLayout(ADestra1,2,2); // QHBoxLayout *MenoInAlto = new QHBoxLayout; // grid->addLayout(MenoInAlto,2,1); QHBoxLayout *InBasso = new QHBoxLayout; grid->addLayout(InBasso,2,1); }
Binary Binary::nand(const Binary& B) { return ~(Binary(*this & B)); }
Binary Binary::nor(const Binary& B) { return ~(Binary(!(i & B.i))); }
Expression_t *Plus(Expression_t *expr1, Expression_t *expr2) { return Binary(expr1, expr2, EXPR_PLUS); }
Expression_t *Concat(Expression_t *expr1, Expression_t *expr2) { return Binary(expr1, expr2, EXPR_CONCAT); }
Expression_t *Divide(Expression_t *expr1, Expression_t *expr2) { return Binary(expr1, expr2, EXPR_DIVIDE); }
Expression_t *Multiply(Expression_t *expr1, Expression_t *expr2) { return Binary(expr1, expr2, EXPR_MULTIPLY); }
Expression_t *Minus(Expression_t *expr1, Expression_t *expr2) { return Binary(expr1, expr2, EXPR_MINUS); }