void run() { char a; //int n; while(1) { system("cls"); menu(); //scanf("%d",&n); printf("choice:\n"); fflush(stdin); a=getchar(); switch(a) { case '1': insert(14); break; case '2': printall();break; case '3': search('a');break; case '4': update('a' );break; case '5': dele( );break; case '6': return; } system("pause"); } }
int main() { while(1) { printf("Array implementation of a stack\n "); printf("1. Insertion \n"); printf("2. Deletion \n"); printf("3. Display \n"); printf("4. Exit \n"); printf("-----------------------------------\n"); printf("Enter your choice (1..4) \n"); scanf("%d", &i); switch(i) { case 1: printf("Insertion \n"); printf("Enter Item :"); scanf("%d", &item); insert(item); break; case 2: printf("Deletion\n"); dele(); break; case 3: display(); break; case 4: exit(1); } } return 0; }
dele::dele(const char *fname_bin) { dele(); fileName = new char[FNLEN]; strncpy(fileName, fname_bin, FNLEN); init(fileName); }
int main() { world odd; world even; int i; init(odd); init(even); eden(even); // simulation for (i = 0; i < CYCLES; ++i) { if ((i % 2)) { update(even,odd); dele(odd); } else { update(odd,even); dele(even); } } }
main() { listnote startptr; listnote head; char a; int i=2,count=1; int num2,num3; float num1; num2=2; num3=3; scanf("%d",&num3); num1=(float)1/num3; num1=num1*11; printf("%f",num1); while(i!=1) { switch (i) { case 2: printf("input the char:"); scanf("\n%c",&a); fun(&startptr,&head,a,count); //printlist(startptr); printlist(head); printf("input the flag:"); scanf("\n%d",&i); count++; break; case 3: printf("the char output is:\n"); a=dele(&head); printf("%c\n",a); printlist(head); printf("input the flag:"); scanf("\n%d",&i); count--; break; default: break; } } //printlist(head); system("pause"); }
int crushposition(int a) { int i,k,l,m,n,j,flag,b,y; int initial,final,profit[20]; for(i=0;i<count2;i++) { for(m=0;m<=4;m++) { for(n=0;n<=4;n++) { duplicate[m][n]=arr[m][n]; } } m=crush[i]; extractor(m,&k,&l); increaseandoccupy(k,l,p); insert(m); initial=duplicateballs(p); while(front!=-1) { m=dele(); if(checkblast(m,p)) { extractor(m,&j,&k); y=cellformat(j,k); blast(j,k,y,p); } } front=-1; rear=-1; final=duplicateballs(p); profit[i]=final-initial; }
static void session_imsgev(struct imsgev *iev, int code, struct imsg *imsg) { struct m_backend *mb = iev->data; switch (code) { case IMSGEV_IMSG: switch (imsg->hdr.type) { case IMSG_MAILDROP_INIT: maildrop_init(iev, imsg, mb); break; case IMSG_MAILDROP_UPDATE: update(iev, imsg, mb); break; case IMSG_MAILDROP_RETR: retr(iev, imsg, mb); break; case IMSG_MAILDROP_DELE: dele(iev, imsg, mb); break; case IMSG_MAILDROP_RSET: rset(iev, imsg, mb); break; case IMSG_MAILDROP_LIST: list(iev, imsg, mb); break; case IMSG_MAILDROP_LISTALL: list_all(iev, imsg, mb); break; default: logit(LOG_DEBUG, "%s: unexpected imsg %u", __func__, imsg->hdr.type); break; } break; case IMSGEV_EREAD: case IMSGEV_EWRITE: case IMSGEV_EIMSG: fatal("maildrop: imsgev read/write error"); break; case IMSGEV_DONE: event_loopexit(NULL); break; } }
void run() { char ch; while(1) { menu(); ch=getch(); switch(ch) { case '1': insert(); break; case '2': printall(); break; case '3': search(); break; case '4': dele(); break; case '5': modify(); break; case '6': return; } system("pause"); } }
/* AUTF8String GetDocText (in nsIDOMDocument doc); */ NS_IMETHODIMP nsDomAttUtil::GetDocText(nsIDOMDocument *doc, nsACString & _retval ) { nsCOMPtr<nsIDOMElement> dele(nsnull); nsCString nsValue; doc->GetDocumentElement(getter_AddRefs(dele)); nsCOMPtr<nsIDOM3Node> nsEle=do_QueryInterface(dele); if(nsEle!=nsnull) { nsString Value; nsEle->GetTextContent(Value); nsValue=NS_ConvertUTF16toUTF8(Value); }else { nsValue=nsCString(""); } nsValue.StripChars("\n"); nsValue.StripWhitespace(); _retval=nsValue; return NS_OK; }
void Run() { int i; while(1) { menu(); printf("선택:"); fflush(stdin); scanf("%d",&i); switch(i) { case 1:push_front();break; case 2:printall();break; case 3:search();break; case 4:change();break; case 5:dele();break; default:return; } } }
int xuanze()//选择界面 { printf(" ******************欢迎进入学生管理系统******************\n"); printf("\n"); printf(" 1.学生信息的录入 \n "); printf(" 2.学生信息的查询 \n "); printf(" 3.学生信息的修改 \n "); printf(" 4.学生信息的删除 \n "); printf(" 5.学生信息的添加 \n "); printf(" 6.学生信息的退出 \n "); printf("请选择:(0-6)\n"); int num; scanf("%d",&num); switch (num) { case 1: input(); break; case 2: chaxun(); break; case 3: xiugai(); break ; case 4: dele(); break; case 5: add(); break; case 6: tuichu(); break; default: jiemian(); } return 0; }
int main( void ) { sysInit(); /* USB Power dinyalakan supaya memory USB bisa dipakai */ PCONP |= 0x80000000; FIO0DIR = LED_UTAMA; FIO0CLR = LED_UTAMA; FIO1DIR = 0xFFFFFFFF; #ifdef PAKAI_SERIAL_3 /* PCONP enable UART3 */ PCONP |= BIT(25); /* PCLK UART3, PCLK = CCLK */ PCLKSEL1 &= ~(BIT(18) | BIT(19)); PCLKSEL1 |= BIT(18); /* init TX3, RX3 */ PINSEL1 &= ~(BIT(18) | BIT(19) | BIT(20) | BIT(21)); PINSEL1 |= (BIT(18) | BIT(19)); PINSEL1 |= (BIT(20) | BIT(21)); PINSEL1 &= ~(BIT(16) | BIT(17)); /* TXDE di highkan */ FIO0DIR |= TXDE; //FIO0SET = TXDE; // on ---> bisa kirim //FIO0SET &= ~TXDE; // off ---> gak bisa kirim //FIO0CLR = TXDE; FIO0SET = TXDE; FIO0DIR |= RXDE; FIO0SET = RXDE; #endif #ifdef PAKAI_SERIAL_2 /* PCONP enable UART2 */ PCONP |= BIT(24); /* PCLK UART2, PCLK = CCLK */ PCLKSEL1 &= ~(BIT(16) | BIT(17)); PCLKSEL1 |= BIT(16); /* init TX2, RX2 */ PINSEL0 |= (BIT(20) | BIT(22)); #endif /* untuk cek blinking saat system boot */ #ifdef CEK_BLINK int t=0; while(t<5) { dele(1000000); FIO0CLR = LED_UTAMA; dele(1000000); FIO0SET = LED_UTAMA; t++; } #endif xSerialPortInitMinimal( BAUD_RATE, configMINIMAL_STACK_SIZE ); #ifdef PAKAI_SERIAL_2 serial2_init( BAUD_PM, (1 * configMINIMAL_STACK_SIZE) ); #endif #ifdef PAKAI_SERIAL_3 serial3_init( BAUD_PM, (1 * configMINIMAL_STACK_SIZE) ); #endif #ifdef PAKAI_ADC init_gpio_adc(); init_gpio_mmc(); init_spi_mmc(0); // untuk adc dan mmc #endif #ifdef jalankan init_led_utama(); start_ether(); #if (defined(PAKAI_PM) && defined(AMBIL_PM)) //init_task_pm(); #endif init_shell(); vTaskStartScheduler(); /* Will only get here if there was insufficient memory to create the idle task. */ return 0; #endif
int smunge (userT *user) { // Interactively deals with users pop commands, // servicing them from the users pop servers, // smunging the results as needed. int argc; char argv0[MAX_ARG_LEN]; char argv1[MAX_ARG_LEN]; char argv2[MAX_ARG_LEN]; char argv3[MAX_ARG_LEN]; int i; char response[MAX_LINE]; if (!user || (user->fd < 1)) { return -1; } while (user->fd > 0) { watchdog (user); if (user->fd < 0) { return (-1); } argc=get_command (&user->fd, argv0, argv1, argv2, argv3); if (argc < 0) { // there was a problem. return (0); } else if (argc) { if (!strcmp (argv0, "QUIT")) { quit (user); ok (user->fd, "Have a nice day"); return (0); } else if (!strcmp (argv0, "DBUG") && (LOG_LEVEL==666)) { debug (user); } else if (!strcmp (argv0, "STAT")) { long messages = 0; long size = 0; user->time = time(NULL); for (i=0; i < user->mailboxes; i++) { if (user->mailbox[i].fd > 0) { if (status (user, i, &messages, &size) == -1) { return (0); } } } snprintf (response, MAX_LINE-1, "%ld %ld", messages, size); ok (user->fd, response); } else if (!strcmp (argv0, "LIST")) { user->time = time(NULL); // if given with no arguments if (argc == 1) { if (list (user) == -1) { return (0); } } else { if (list_s (user, atol(argv1)) == -1) { return (0); } } } else if (!strcmp (argv0, "UIDL")) { user->time = time(NULL); // if given with no arguments if (argc == 1) { if (uidl (user) == -1) { return (0); } } else { if (uidl_s (user, atol(argv1)) == -1) { return (0); } } } else if ((argc == 2) && (!strcmp (argv0, "RETR"))) { user->time = time(NULL); if (retr (user, atol(argv1), -1) == -1) { return (0); } } else if ((argc == 2) && (!strcmp (argv0, "DELE"))) { user->time = time(NULL); if (dele (user, atol(argv1)) == -1) { return (0); } } else if ((argc == 3) && (!strcmp (argv0, "TOP"))) { user->time = time(NULL); if (atol(argv2) < 0) { err (user, "Need to supply a non-negative number of lines"); } else if (retr (user, atol(argv1), atol(argv2)) == -1) { return (0); } } else if (!strcmp (argv0, "RSET")) { user->time = time(NULL); if (rset (user) == -1) { return (0); } } else if (!strcmp (argv0, "NOOP")) { user->time = time(NULL); ok (user->fd, "Keeping out of trouble"); } else { user->time = time(NULL); snprintf (response, MAX_LINE-1, "Invalid commmand - %s", argv0); err (user, response); } } else { user->time = time(NULL); err (user, "Talk to me"); } } return (0); }
int XC::YieldSurfaceSection2d::setTrialSectionDeformation(const XC::Vector &def) { ys->update(); // important use_Kr = use_Kr_orig; // split_step = false; // once determined, leave it till convergence eTrial = def; dele = eTrial - eCommit; getSectionStiffness(ks); double EA = ks(0,0); double EI = ks(1,1); s(0) = sCommit(0) + EA*dele(0); s(1) = sCommit(1) + EI*dele(1); if(ys->getTrialForceLocation(s) <= 0) return 0; // case: if it shoots through // use dF return to surface int driftOld = ys->getCommitForceLocation(); if(driftOld < 0) // Inside { use_Kr = false; split_step = true; surfaceForce = s; ys->setToSurface(surfaceForce, ys->dFReturn); //dFReturn, ConstantYReturn, RadialReturn ys->getTrialGradient(G, surfaceForce); } // Now we know that force point has drifted from the surface else if(driftOld == 0) // On surface { ys->getCommitGradient(G); surfaceForce = sCommit; } else // driftOld outside - bug or bad constraints or continued from not converged state { std::cerr << "WARNING: XC::YieldSurfaceSection2d::setTrialSectionDeformation, driftOld outside [" << getTag()<<"]\n"; } double dF_in0 = s(0) - surfaceForce(0); double dF_in1 = s(1) - surfaceForce(1); double g0 = G(0,0); double g1 = G(1,0); Ktp(0,0) = EA; Ktp(1,1) = EI; ys->addPlasticStiffness(Ktp); double inv = 1/(Ktp(0,0)*g0*g0 + Ktp(1,1)*g1*g1); double lamda = inv*(g0*dF_in0 + g1*dF_in1); if(fabs(lamda) < 1e-8) lamda = 0.0; // to get rid of -1e-15 etc if(lamda < 0) { use_Kr = false; lamda = 0.0; } //int grow= ys->modifySurface(lamda, surfaceForce, G); ys->modifySurface(lamda, surfaceForce, G); // used to do: (not tested shrinking yet) // if(grow < 0) // algo = ys->ConstantYReturn; // else // algo = algo_orig; if(use_Kr) { ks(0,0) = EA - EA*EA*g0*g0*inv; ks(0,1) = -1*EA*g0*g1*EI*inv; ks(1,0) = ks(0,1); ks(1,1) = EI - EI*EI*g1*g1*inv; } if(split_step) { s(0) = s(0) - EA*g0*lamda; s(1) = s(1) - EI*g1*lamda; } else { if(use_Kr) s= surfaceForce + ks*dele; } ys->setToSurface(s, ys->ConstantYReturn); // used to do centroid return // then force-balance using ConstantYReturn // comp/tension issue: always use constantP return 0; }
void MainWindow::createActions() { newAction = new QAction(tr(&New),this); newAction->setIcon(); newAction->setShortcut(QKeySequence::New); newAction->setStatusTip(tr("Create a new spreadsheet file")); connect(newAction,SIGNAL(triggered()), this,SLOT(newFile())); openAction = new QAction(tr(&Open),this); openAction->setIcon(); openAction->setShortcut(QKeySequence::Open); openAction->setStatusTip(tr("Open an existing spreadsheet file")); connect(openAction,SIGNAL(triggered()), this,SLOT(open())); saveAction = new QAction(tr(&Save),this); saveAction->setIcon(); saveAction->setShortcut(QKeySequence::Save); saveAction->setStatusTip(tr("File saved")); connect(saveAction,SIGNAL(triggered()), this,SLOT(save())); saveAsAction = new QAction(tr(Save &As),this); saveAsAction->setStatusTip(tr("File saved")); connect(saveAsAction,SIGNAL(triggered()), this,SLOT(saveAs())); for(int i = 0;i < MaxRecentFiles;i++){ recentFileActions[i] = new QAction(this); recentFileActions[i]->setVisible(false); connect(recentFileActions[i],SIGNAL(triggered()), this,SLOT(openRecentFile())); } exitAction = new QAction(tr(E&xit),this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction,SIGNAL(triggered()), this,SLOT(close())); cutAction = new QAction(tr("Cu&t"),this); cutAction->setShortcut(QKeySequence::Cut); cutAction->setStatusTip((tr("File cut"))); connect(cutAction,SIGNAL(triggered()), spreadsheet,SLOT(cut())); copyAction = new QAction(tr("&Copy"),this); copyAction->setShortcut(QKeySequence::Copy); copyAction->setStatusTip(tr("File copied")); connect(copyAction,SIGNAL(triggered()), spreadsheet,SLOT(copy())); pasteAction = new QAction(tr("&Paste")); pasteAction->setShortcut(QKeySequence::Paste); pasteAction->setStatusTip(tr("File pasted")); connect(pasteAction,SIGNAL(triggered()), spreadsheet,SLOT(paste())); deleteAction = new QAction(tr("&Delete"),this); deleteAction->setShortcut(QKeySequence::Delete); deleteAction->setStatusTip(tr("File deleted")); connect(deleteAction,SIGNAL(triggered()), spreadsheet,SLOT(dele())); selectAllAction = new QAction(tr("&All"),this); selectAllAction->setShortcut(QKeySequence::SelectAll); selectAllAction->setStatusTip(tr("Select all the cells in the spreadsheet")); connect(selectAllAction,SIGNAL(triggered()), spreadsheet,SLOT(selectAll())); showGridAction = new QAction(tr("&Show Grid"),this); showGridAction->setCheckable(true); showGridAction->setChecked(spreadsheet->showGrid()); showGridAction->setStatusTip(tr("Show or hide the spreadsheet's grid")); connect(showGridAction,SIGNAL(toggled(bool)), spreadsheet,SLOT(setShowGrid(bool))); }
void PopCommand::execute() { if ( d->done ) return; switch ( d->cmd ) { case Quit: log( "Closing connection due to QUIT command", Log::Debug ); d->pop->setState( POP::Update ); d->pop->ok( "Goodbye" ); break; case Capa: { EString c( "TOP\r\n" "UIDL\r\n" "SASL\r\n" "USER\r\n" "RESP-CODES\r\n" "PIPELINING\r\n" "IMPLEMENTATION Archiveopteryx POP3 Server, " "http://archiveopteryx.org.\r\n" ); if ( Configuration::toggle( Configuration::UseTls ) ) c.append( "STLS\r\n" ); c.append( ".\r\n" ); d->pop->ok( "Capabilities:" ); d->pop->enqueue( c ); } break; case Stls: if ( !startTls() ) return; break; case Auth: if ( !auth() ) return; break; case User: if ( !user() ) return; break; case Pass: if ( !pass() ) return; break; case Apop: if ( !apop() ) return; break; case Session: if ( !session() ) return; break; case Stat: if ( !stat() ) return; break; case List: if ( !list() ) return; break; case Top: if ( !retr( true ) ) return; break; case Retr: if ( !retr( false ) ) return; break; case Dele: if ( !dele() ) return; break; case Noop: d->pop->ok( "Done" ); break; case Rset: d->pop->ok( "Done" ); break; case Uidl: if ( !uidl() ) return; break; } finish(); }