int main (void) { void *h = dlopen ("$ORIGIN/unload8mod1.so", RTLD_LAZY); if (h == NULL) { puts ("dlopen unload8mod1.so failed"); return 1; } void *h2 = dlopen ("$ORIGIN/unload8mod1x.so", RTLD_LAZY); if (h2 == NULL) { puts ("dlopen unload8mod1x.so failed"); return 1; } dlclose (h2); int (*mod1) (void) = dlsym (h, "mod1"); if (mod1 == NULL) { puts ("dlsym failed"); return 1; } mod1 (); dlclose (h); return 0; }
int main(int argc, char const *argv[]) { printf("\t%d\n", mod1()); printf("\t%d\n", mod2()); printf("\t%d\n", mod3()); return 0; }
int main () { if (div1 (-(1 << 7)) != 1 << 7) abort (); if (div2 (-(1 << 15)) != 1 << 15) abort (); if (div3 (-(1 << 7), -1) != 1 << 7) abort (); if (div4 (-(1 << 15), -1) != 1 << 15) abort (); if (mod1 (-(1 << 7)) != 0) abort (); if (mod2 (-(1 << 15)) != 0) abort (); if (mod3 (-(1 << 7), -1) != 0) abort (); if (mod4 (-(1 << 15), -1) != 0) abort (); if (mod5 (0x50000000, 2) != 0) abort (); if (mod6 (0x50000000, 2) != 0) abort (); exit (0); }
int main(int argc, const char *argv[]) { int a,b,ad,su,mu,de,mo; char i; fun add1;//申请一个地址空间 add1=add;//把函数add的入口地址赋给add1 fun subtract1; subtract1=subtract; fun multiply1; multiply1=multiply; fun dev1; dev1=dev; fun mod1; mod1=mod; while(1) { printf("Input a symbol:\n"); scanf("%c",&i); if(i=='#') break; printf("Input num1:\n"); scanf("%d",&a); printf("Input num2:\n"); scanf("%d",&b); ad=add1(a,b); getchar();//因为输入完成之后要回车才能输入字符,程序会把回车当字符读入造成程序出乱,所以加上getchar() switch(i) { case '+': ad=add1(a,b); printf("%d + %d= %d\n",a,b,ad); break; case '-': su=subtract1(a,b); printf("%d - %d= %d\n",a,b,su); break; case '*': mu=multiply1(a,b); printf("%d * %d= %d\n",a,b,mu); break; case '/': de=dev1(a,b); printf("%d / %d= %d\n",a,b,de); break; case '%': mo=mod1(a,b); printf("%d %% %d= %d\n",a,b,mo); //打印%的时候 中间要加一个%分开 否则会出错误 break; } } return 0; }
int sc_main (int argc , char *argv[]) { sc_event event1; event1.notify(55, SC_NS); module1 mod1("mod1", event1); sc_start(100, SC_NS); return 0; }
real* modA(real* x, real* y, int n) { int i; real* res= (real*)malloc(sizeof(real)*n); if ( !res ) eprintf("malloc failed in modA"); for ( i= 0; i < n; ++i ) res[i]= mod1(x[i], y[i]); return res; }
int main() { Module mod1(100, "Feeding"); Student people1("Oz", "Computer Science & Mathematics", 1, "King", "Hearts", "Black", 1732050); Student people2("Ozkh", "Unemployed", 0, "Joker", "Clubs", "Red", 1732050); Student people3("Othman", "Electrical & Electronic Engineering", 1, "Five", "Diamonds", "Black", 1732050); mod1.enrolStudent(people1); mod1.enrolStudent(people2); mod1.enrolStudent(people3); std::cout << "\n" << mod1; mod1.printAttendanceRegister(); }
int main() { // ======================================================================== std::cout << " Create an amino acid sequence" << std::endl; libaas::AminoAcidSequence aas("DCGTQS"); // ======================================================================== std::cout << " Add a standard modification" << std::endl; libaas::modifications::Modification mod1("Acetyl"); aas.applyModificationAtPosition(mod1, 2); libaas::modifications::Modification mod2("Oxidation"); libaas::AminoAcidSequence::ModificationList ml; ml.push_back(mod2); aas.applyFixedModifications(ml); // ======================================================================== std::cout << " Add a custom modification" << std::endl; // start creating custom raw modification libaas::modifications::RawModificationImpl::RawModificationImplKeyType id = "My Mod"; libaas::String name = "My mod"; libaas::String fullName = "My mod is special"; libaas::Bool verified = true; libaas::modifications::RawModificationImpl customMod(id, name, fullName, verified); libaas::String altName = "My mod is super special"; customMod.addAltName(altName); libaas::Stoichiometry myStoichiometry; myStoichiometry.set(libaas::elements::Element(8), 1); myStoichiometry.set(libaas::elements::Element(1), 1); customMod.setStoichiometry(myStoichiometry); customMod.addSpecificity( libaas::modifications::Specificity( libaas::aminoAcids::RawAminoAcid('D'), libaas::modifications::Specificity::ANYWHERE, libaas::modifications::Specificity::ARTEFACT)); // add custom raw modification addRawModification(customMod); aas.applyModificationAtPosition(id, 1); // ======================================================================== std::cout << " Remove a modifications" << std::endl; // ======================================================================== std::cout << " a remove mod by key" << std::endl; aas.remove("Oxidation"); // ======================================================================== std::cout << " b remove mod by ref" << std::endl; aas.remove(mod1); // ======================================================================== std::cout << " Apply stoichiometry config" << std::endl; libaas::StoichiometryConfigImpl::StoichiometryConfigImplKeyType custom_key = "My_Stoichiometry_Configuration 1"; libaas::StoichiometryConfigImpl customConfig(custom_key); // create custom element ... libaas::elements::ElementImpl customElement( libaas::elements::ElementImpl::getNextId(), "C", 6); customElement.addIsotope(13.0034, 1.0); libaas::elements::Element customElementRef(customElement); // ... and add by instance of an element customConfig.insertElement( libaas::elements::Element(customElement.getId())); addStoichiometryConfig(customConfig); aas.applyAminoAcidStoichiometryConfig(custom_key); aas.applyModificationStoichiometryConfig(custom_key); // ======================================================================== std::cout << " Retrieve the stoichiometry" << std::endl; aas.getStoichiometry(); return 0; }