示例#1
0
Vertex searching(Vertex t){
  if ((! vertex_isempty(t->left)) && ((t->left)->finish == 0))
    return searching(t->left);
    else if ((! vertex_isempty(t->right)) && ((t->right)->finish == 0))
      return searching(t->right);
    else
      return t;
}
示例#2
0
int main()
{
    int n, item,L;
    Nodeptr start,np,last;
    start=NULL;

    printf("Enter your number(-1 to finish):\n");
    while (scanf("%d",&n)==1)
    {
        if(n==-1)
            break;

        np=makeNode(n);

        if(start==NULL)
            start=np;
        else
            last->link=np;

        last=np;
    }

    printf("\nEnter search item:\n ");
    scanf("%d", &item);

    L=searching(start, item);

    if(L==0)
        printf("Not Found");
    else
        printf("Found is location %d",L);

    return 0;
}
示例#3
0
int main()
{
    root=NULL;
    int ch,k,n;
    do
    {
        printf("1:Insertion 2:Traversing 3:Searching \n");
        printf("Enter your choice\n");
        scanf("%d",&ch);
        switch(ch)
        {
            case 1:create();
            inorder_traversal(root);
            break;
            case 2:inorder_traversal(root);
            break;
            case 3:printf("Enter the item to search\n");
            scanf("%d",&n);
                searching(root,n);
            break;
            default:printf("Wrong choice!\n");
        }
        printf("\nWant to continue type 1\n");
        scanf("%d",&k);
    }while(k==1);
    return 0;
}
示例#4
0
文件: b-tree.c 项目: nicoede/FinalPra
int main() {
      int val, ch;
      while (1) {
              printf("1. Inserção\t2. Deletar\n");
              printf("3. Procurar\t4. Mostrar\n");
              printf("5. Sair\nEntre com a opcao:");
              scanf("%d", &ch);
              switch (ch) {
                      case 1:
                              printf("Entre com o elemento a ser inserido:");
                              scanf("%d", &val);
                              insertion(val);
                              break;
                      case 2:
                              printf("Entre com o elemento que deseja remover:");
                              scanf("%d", &val);
                              deletion(val, root);
                              break;
                      case 3:
                              printf("Entre com o elemento que deseja procurar");
                              scanf("%d", &val);
                              searching(val, &ch, root);
                              break;
                      case 4:
                              traversal(root);
                              break;
                      case 5:
                              exit(0);
                      default:
                              printf("Voce entrou com uma opcao invalida!!\n");
                              break;
              }
              printf("\n");
      }
}
示例#5
0
Tip* TipCollection::canvasObjectToTip(CanvasObjectManager::Object obj)
{
   switch(obj) {
      case CanvasObjectManager::Object::DialInfo:
         return dialPad();
      case CanvasObjectManager::Object::EndCall :
         return endCall();
      case CanvasObjectManager::Object::Ringing :
         return ringing();
      case CanvasObjectManager::Object::Network :
         return connectionLost();
      case CanvasObjectManager::Object::DropInfo:
         return removeConference();
      case CanvasObjectManager::Object::ConfInfo:
         return conference();
      case CanvasObjectManager::Object::AccountDown:
         return networkLost();
      case CanvasObjectManager::Object::Searching:
         return searching();
      case CanvasObjectManager::Object::NoObject:
      case CanvasObjectManager::Object::AutoComplete:
         return nullptr;
   }
   return nullptr;
}
示例#6
0
void KRSearchMod::scanURL(QUrl url)
{
    if (stopSearch) return;

    unScannedUrls.push(url);
    while (!unScannedUrls.isEmpty()) {
        QUrl urlToCheck = unScannedUrls.pop();

        if (stopSearch) return;

        if (query->isExcluded(urlToCheck)) {
            if (!query->searchInDirs().contains(urlToCheck))
                continue;
        }

        if (scannedUrls.contains(urlToCheck))
            continue;
        scannedUrls.push(urlToCheck);

        emit searching(urlToCheck.toDisplayString(QUrl::PreferLocalFile));

        if (urlToCheck.isLocalFile())
            scanLocalDir(urlToCheck);
        else
            scanRemoteDir(urlToCheck);
    }
}
示例#7
0
 lbool context::check(model_ref & m) {
     flet<bool> searching(m_searching, true);
     lbool r;
     r = get_smt_kernel().check();
     if (r != l_false)
         get_smt_kernel().get_model(m);
     return r;
 }
示例#8
0
void searching(struct node* root,int item)
{
    if(root->info==item)
    {
        printf("Item found:\n");
    }
    else
    {
        if(root->info>item)
        {
            searching(root->left,item);
        }
        else
        {
            searching(root->right,item);
        }
   }
}
float lumcline2(__global float *sunGeom,
                __global float *sunVarGeom,
                __global float *sunSlopeGeom,
                __local float *gridGeom,
                __constant float *const_f,
                __constant float *const_i,
                
                __global float *horizonArr,
                __constant float *z,
                const int horizonOff)
{
    unsigned int gid = get_global_id(0);
    unsigned int gsz = const_i[0]*const_i[1];
    float s = 0.0f;
    
    sunVarGeom[gid] = 0.0f;	/* no shadow */
    
    if (const_i[28]) {
        if (const_i[29]) {
            /* Start is due east, sungeom->timeangle = -pi/2 */
            float horizPos = sunVarGeom[8*gsz+gid] / const_f[19];
            int lowPos = (int) horizPos;
            int highPos = lowPos + 1;
            
            if (highPos == const_i[7])
                highPos = 0;
            
            float horizonHeight = const_f[0] * ((1.0f - (horizPos - lowPos)) * horizonpointer[lowPos]
                                                + (horizPos - lowPos) * horizonArr[highPos+horizonOff]);
            
            int isShadow = horizonHeight > sunVarGeom[5*gsz+gid];
            sunVarGeom[gid] = (float) isShadow;
            
            if (!isShadow)
                s = sunSlopeGeom[gsz+gid] * cos(-sunGeom[7*gsz+gid] - sunSlopeGeom[gid])
                    + sunSlopeGeom[2*gsz+gid];	/* Jenco */
        } else {
            int r;
            while ((r = searching(sunVarGeom, gridGeom, const_f, const_i, z)) == 1) {}
            
            if (r == 2)
                sunVarGeom[gid] = 1.0f;	/* shadow */
            else
                s = sunSlopeGeom[gsz+gid] * cos(-sunGeom[7*gsz+gid] - sunSlopeGeom[gid])
                    + sunSlopeGeom[2*gsz+gid];	/* Jenco */
        }
    } else {
        s = sunSlopeGeom[gsz+gid] * cos(-sunGeom[7*gsz+gid] - sunSlopeGeom[gid])
            + sunSlopeGeom[2*gsz+gid];	/* Jenco */
    }
    
    if (s < 0.0f)
        return 0.0f;
    else
        return s;
}
QNetworkRegistrationDummy::QNetworkRegistrationDummy
        ( const QString& service, QObject *parent )
    : QNetworkRegistrationServer( service, parent )
{
    QTimer::singleShot( 500, this, SLOT(searching()) );
    QTimer::singleShot( 5000, this, SLOT(home()) );
    QTimer::singleShot( 200, this, SLOT(initDone()) );

    updateRegistrationState( QTelephony::RegistrationNone );
}
示例#11
0
int SearchOpenFiles::searchOpenFile(KTextEditor::Document *doc, const QRegExp &regExp, int startLine)
{
    if (m_statusTime.elapsed() > 100) {
        m_statusTime.restart();
        emit searching(doc->url().pathOrUrl());
    }

    if (regExp.pattern().contains("\\n")) {
        return searchMultiLineRegExp(doc, regExp, startLine);
    }

    return searchSingleLineRegExp(doc, regExp, startLine);
}
示例#12
0
文件: MOVE.C 项目: MegaGod/TW
void quick( unsigned int *x, unsigned int *y ) {
	register int key;

	dispkey( CNTRL_Q );
	waitkbd( 3, 2 );
	key = ebioskey( 0 ) & 0xff;
	prchar( key, 0, 3, 2 );
	if ( !isalpha( key ) && !iscntrl( key ) ) {
		return;
	}
	switch ( key & 0x1f ) {
	case 'r' - 'a' + 1:
		topfile( x );
		break;
	case 'c' - 'a' + 1:
		endfile( x );
		break;
	case 'f' - 'a' + 1:
		searching( x, y );
		break;
	case 'a' - 'a' + 1:
		replacing( x, y );
		break;
	case 'y' - 'a' + 1:
		deltoendline( *x, *y );
		break;
	case 'l' - 'a' + 1:
		loadtoline( curline->text );
		refreshline( 0, *y );
		break;
	case 'b' - 'a' + 1:
		gobeginblk( x );
		break;
	case 'k' - 'a' + 1:
		goendblk( x );
		break;
	case 'd' - 'a' + 1:
		endline( x );
		break;
	case 's' - 'a' + 1:
		home( x );
		break;
	case 'x' - 'a' + 1:
		bottom_of_page( );
		break;
	case 'e' - 'a' + 1:
		top_of_page( );
		break;
	}
}
示例#13
0
  int main() {
        int val, ch;
	long i;
        double insert_stime, insert_etime;
        double search_stime, search_etime;
        double delete_stime, delete_etime;
	double traverse_stime, traverse_etime;

        printf("\n");
	/* insert into B-Tree random values */
	printf("============================================\n");
        printf("Insert in B-Tree\n");
	insert_stime = omp_get_wtime();
	#pragma omp for
        for (i=0;i<100000000;i++)
        {
		val = i;
        	insertion(val);
	}
	insert_etime = omp_get_wtime();
	printf("Insert time: %10.4f\n", insert_etime - insert_stime);
	
	/* search in the B-Tree the last val entered */
	printf("============================================\n");
	printf("Search in B-Tree\n");
	search_stime = omp_get_wtime();
	searching(val, &ch, root);
	search_etime = omp_get_wtime();
	printf("Search time: %10.4f\n", search_etime - search_stime);

	/* delete from the B-Tree the last val entered*/
	printf("============================================\n");
	printf("Delete from B-Tree\n");
	delete_stime = omp_get_wtime(); 
	deletion(val, root);
	delete_etime = omp_get_wtime();
	printf("Insert time: %10.4f\n", delete_etime - delete_stime);

	/* traverse the entire B-Tree */
	printf("============================================\n");
	printf("Traversing the B-Tree.....\n");
	traverse_stime = omp_get_wtime();
	traversal(root);
	traverse_etime = omp_get_wtime();
	printf("Insert time: %10.4f\n", traverse_etime - traverse_stime);

	printf("\n");
        
  }
示例#14
0
void searching(long long int val, int *pos, struct btreeNode *myNode) {
      if (!myNode) {
              return;
      }

      if (val < myNode->val[1]) {
              *pos = 0;
      } else {
              for (*pos = myNode->count;
                      (val < myNode->val[*pos] && *pos > 1); (*pos)--);
              if (val == myNode->val[*pos]) {
                      return;
              }
      }
      searching(val, pos, myNode->link[*pos]);
      return;
}
示例#15
0
    foreach (QString fileName, m_files) {
        if (m_cancelSearch) {
            break;
        }

        if (m_statusTime.elapsed() > 100) {
            m_statusTime.restart();
            emit searching(fileName);
        }

        if (m_regExp.pattern().contains("\\n")) {
            searchMultiLineRegExp(fileName);
        }
        else {
            searchSingleLineRegExp(fileName);
        }
    }
示例#16
0
文件: b-tree.c 项目: nicoede/FinalPra
/* search val in B-Tree */
void searching(int val, int *pos, struct btreeNode *myNode) {
      if (!myNode) {
              return;
      }

      if (val < myNode->val[1]) {
              *pos = 0;
      } else {
              for (*pos = myNode->count;
                      (val < myNode->val[*pos] && *pos > 1); (*pos)--);
              if (val == myNode->val[*pos]) {
                      printf("Given data %d is present in B-Tree", val);
                      return;
              }
      }
      searching(val, pos, myNode->link[*pos]);
      return;
}
示例#17
0
 int main(void)
 {
	struct node *temp,*pa;
	int i=0,n,choice,ch;
	printf("\nEnter no of nodes to be inserted: ");
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		temp=malloc(sizeof(struct node));		// getting no of nodes and elements as much
		printf("\nEnter data for node %d: ",i+1);
		scanf("%d",&temp->data);
		temp->r=NULL;
		if(!i)
		{
			first=temp;
			first->l=NULL;
			pa=first;
		}
		pa->r=temp;
		temp->l=pa;
		pa=temp;
	}
	do
	{
		printf("\n1.Deletion at start 2. Deletion at end 3. Deletion at position 4. Deletion by value 5. Searching\n");
		scanf("%d",&choice);
		if(choice==1)
			delatstart();
		else if(choice==2)
			delatend();
		else if(choice==3)
			delatpos();			//getting choice of operation and calling certain function
		else if(choice==4)
			delbyval();
		else if(choice==5)
			searching(); 
		disp();
		printf("\nPress 1 to continue.. : ");
		scanf("%d",&ch);
	}while(ch==1);
        printf("\n\n");		
	return;
 } 
示例#18
0
int main (int argc, char *argv[])
{
	int *arr, a,i, search,cont;
	printf("Ingrese la cantidad de datos a ingresar \n");
	scanf("%d", &a);
	arr=(int*)malloc(a*sizeof(int));
	for (i = 0; i < a; i += 1)
	{
		arr[i]=i+1;
		printf("%d ", arr[i]);
	}
	printf(" \n");
	printf("Ingrese Numero para buscar \n");
	scanf("%d", &search);
	cont=searching(arr, a, search);
	printf("%d \n", cont);
	free(arr);
	return 0;
}
示例#19
0
SearchPage::SearchPage(QWidget *p)
    : QWidget(p)
    , state(-1)
    , model(this)
    , proxy(this)
{
    setupUi(this);
    addToPlayQueue->setDefaultAction(StdActions::self()->addToPlayQueueAction);
    replacePlayQueue->setDefaultAction(StdActions::self()->replacePlayQueueAction);
    locateAction=new Action(Icon("edit-find"), i18n("Locate In Library"), this);
    view->allowTableView(new SearchTableView(view));
    view->addAction(StdActions::self()->addToPlayQueueAction);
    view->addAction(StdActions::self()->replacePlayQueueAction);
    view->addAction(StdActions::self()->addWithPriorityAction);
    view->addAction(StdActions::self()->addToStoredPlaylistAction);
    #ifdef TAGLIB_FOUND
    #ifdef ENABLE_DEVICES_SUPPORT
    view->addAction(StdActions::self()->copyToDeviceAction);
    #endif
    #endif // TAGLIB_FOUND
    view->addAction(locateAction);

    connect(this, SIGNAL(add(const QStringList &, bool, quint8)), MPDConnection::self(), SLOT(add(const QStringList &, bool, quint8)));
    connect(this, SIGNAL(addSongsToPlaylist(const QString &, const QStringList &)), MPDConnection::self(), SLOT(addToPlaylist(const QString &, const QStringList &)));
    connect(&model, SIGNAL(searching()), view, SLOT(showSpinner()));
    connect(&model, SIGNAL(searched()), view, SLOT(hideSpinner()));
    connect(&model, SIGNAL(statsUpdated(int, quint32)), this, SLOT(statsUpdated(int, quint32)));
    connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions()));
    connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &)));
    connect(view, SIGNAL(searchItems()), this, SLOT(searchItems()));
    connect(MPDConnection::self(), SIGNAL(stateChanged(bool)), this, SLOT(setSearchCategories()));
    connect(locateAction, SIGNAL(triggered()), SLOT(locateSongs()));
    proxy.setSourceModel(&model);
    view->setModel(&proxy);
    view->setMode(ItemView::Mode_List);
    view->setPermanentSearch();
    setSearchCategories();
    view->setSearchCategory(Settings::self()->searchCategory());
    statsUpdated(0, 0);
}
示例#20
0
static void MainL()
	{
	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-STDLIB-LEGACY-TMISC-0001 TMISC tests "));

	random_numbers();
	sorting();
	searching();
	setjmp_longjmp();
	casecmp();
	sscanf_test();

	int argsc = 5;
	char *argsv[]=
		{
		"tmisc", "This", "is", "a", "test.",
		};
	arguments(argsc, argsv);

	strtod_test();
	va_args_test();
	sprintf_test();
	}
示例#21
0
void allTests()
	{
	int err=chdir("C:\\");
	test(err==0);

	make_tree();
	create_files();
	renaming();
	directory();
	attributes();
	searching();
	deletion();
	temporary_files();

	if (close_console)
		{
		test_Close();
		close(0);
		close(1);
		close(2);

		CloseSTDLIB();
		}
	}
示例#22
0
void SoundCloudService::search(const QString &key, const QString &value)
{
    Q_UNUSED(key);

    if (value==currentValue) {
        return;
    }

    clear();
    cancel();

    currentValue=value;

    if (currentValue.isEmpty()) {
        return;
    }

    QUrl searchUrl(constUrl);
    #if QT_VERSION < 0x050000
    QUrl &query=searchUrl;
    #else
    QUrlQuery query;
    #endif
    query.addQueryItem("client_id", constApiKey);
    query.addQueryItem("q", currentValue);
    #if QT_VERSION >= 0x050000
    searchUrl.setQuery(query);
    #endif

    QNetworkRequest req(searchUrl);
    req.setRawHeader("Accept", "application/json");
    job=NetworkAccessManager::self()->get(req);
    connect(job, SIGNAL(finished()), this, SLOT(jobFinished()));
    emit searching();
    emit dataChanged(QModelIndex(), QModelIndex());
}
示例#23
0
cmph_t *fch_new(cmph_config_t *mph, double c)
{
	cmph_t *mphf = NULL;
	fch_data_t *fchf = NULL;
	cmph_uint32 iterations = 100;
	cmph_uint8 restart_mapping = 0;
	fch_buckets_t * buckets = NULL;
	cmph_uint32 * sorted_indexes = NULL;
	fch_config_data_t *fch = (fch_config_data_t *)mph->data;
	fch->m = mph->key_source->nkeys;
	//DEBUGP("m: %f\n", fch->m);
	if (c <= 2) c = 2.6; // validating restrictions over parameter c.
	fch->c = c;
	//DEBUGP("c: %f\n", fch->c);
	fch->h1 = NULL;
	fch->h2 = NULL;
	fch->g = NULL;
	do
	{	  
		if (mph->verbosity)
		{
			fprintf(stderr, "Entering mapping step for mph creation of %u keys\n", fch->m);
		}
		if (buckets) fch_buckets_destroy(buckets);
		buckets = mapping(mph);
		if (mph->verbosity)
		{
			fprintf(stderr, "Starting ordering step\n");
		}
		if (sorted_indexes) free (sorted_indexes);
		sorted_indexes = ordering(buckets);
		if (mph->verbosity)
		{
			fprintf(stderr, "Starting searching step.\n");
		}
		restart_mapping = searching(fch, buckets, sorted_indexes);
		iterations--;
		
        } while(restart_mapping && iterations > 0);
	if (buckets) fch_buckets_destroy(buckets);
	if (sorted_indexes) free (sorted_indexes);
	if (iterations == 0) return NULL;
	mphf = (cmph_t *)malloc(sizeof(cmph_t));
	mphf->algo = mph->algo;
	fchf = (fch_data_t *)malloc(sizeof(fch_data_t));
	fchf->g = fch->g;
	fch->g = NULL; //transfer memory ownership
	fchf->h1 = fch->h1;
	fch->h1 = NULL; //transfer memory ownership
	fchf->h2 = fch->h2;
	fch->h2 = NULL; //transfer memory ownership
	fchf->p2 = fch->p2;
	fchf->p1 = fch->p1;
	fchf->b = fch->b;
	fchf->c = fch->c;
	fchf->m = fch->m;
	mphf->data = fchf;
	mphf->size = fch->m;
	//DEBUGP("Successfully generated minimal perfect hash\n");
	if (mph->verbosity)
	{
		fprintf(stderr, "Successfully generated minimal perfect hash function\n");
	}
	return mphf;
}
示例#24
0
文件: CW.C 项目: kytulendu/TW
int main( int argc, char *argv[] ) {
	/* (x,y) position of edit window. x column, y line -> (0,0) at upper left on screen */
	unsigned int xCursorPos = 0;
	unsigned int yCursorPos = 0;

	unsigned int curmenu = 0x1100;
	int i;

	cwsetup( argc, argv );

	writestatus( 0 );
	writetab( );

	splashscreen( );

	/* Main program loop */
	do {
		dispstrhgc( "   ", wind.col, 2, NORMALATTR );
		i = pulled_down_menu( &curmenu, &xCursorPos, &yCursorPos );
		if ( filename[0] != '\0' ) {
			switch ( i ) {
			case RETKEY:
				keymain = menu_to_key( curmenu );
				break;

			case ESCKEY:
				waitkbd( wind.col + xCursorPos, wind.row + yCursorPos );		/* Show blinking cursor */
				keymain = readkbd( );		/* If keypressed Get it */
				break;

			default:
				keymain = i;
				break;
			}

			while ( keymain != ESCKEY ) {
				if ( ( keymain & 0xff ) >= 32 ) {
					keymain = changekey( keymain );
					if ( insertmode ) {
						if ( !insert_char( keymain, &xCursorPos, &yCursorPos ) ) {
							linetoolong( );
						}
					} else {
						if ( !ovrwrite_char( keymain, &xCursorPos, &yCursorPos ) ) {
							linetoolong( );
						}
					}
					refreshline( xCursorPos, yCursorPos );
				} else {	/*  Function Key  */
					switch ( keymain ) {
					case PGUPKEY:
					case CNTRL_R:
						page_up( );
						break;

					case PGDNKEY:
					case CNTRL_C:
						page_down( );
						break;

					case UPKEY:
					case CNTRL_E:
						cursor_up( );
						break;

					case DNKEY:
					case CNTRL_X:
						cursor_down( yCursorPos );
						break;

					case LEKEY:
					case CNTRL_S:
						cursor_left( &xCursorPos );
						break;

					case 0x2301:
						gobeginblk( &xCursorPos );
						break;

					case 0x2401:
						goendblk( &xCursorPos );
						break;

					case RIKEY:
					case CNTRL_D:
						cursor_right( &xCursorPos, yCursorPos );
						break;

					case CNTRL_W:
						scroll_up( );
						break;

					case CNTRL_Z:
						scroll_down( );
						break;

					case CHOMEKEY:
						top_of_page( );
						break;

					case CPGUPKEY:
						topfile( &xCursorPos );
						break;

					case CENDKEY:
						bottom_of_page( );
						break;

					case CPGDNKEY:
						endfile( &xCursorPos );
						break;

					case DELKEY:
					case CNTRL_G:
						delete_char( xCursorPos );
						refreshline( xCursorPos, yCursorPos );
						changeflag = YES;
						break;

					case CNTRL_T:
						delete_word( xCursorPos );
						refreshline( xCursorPos, yCursorPos );
						changeflag = YES;
						break;

					case CNTRL_Y:
						delete_line( );
						changeflag = YES;
						break;

					case CNTRL_M:
					case RETKEY:
						if ( insertmode == NO ) {
							returnkey( &xCursorPos, yCursorPos );
						} else {
							ret_with_ins( &xCursorPos, yCursorPos );
							changeflag = YES;
						}
						break;

					case BSKEY:
					case CNTRL_H:
						backspace( &xCursorPos );
						yCursorPos = findrow( );
						refreshline( 0, yCursorPos );
						changeflag = YES;
						break;

					case INSKEY:
					case CNTRL_V:
						insertmode = !insertmode;
						writeinsmode( );
						break;

					case CNTRL_N:
						insert_ret( &xCursorPos );
						break;

					case F10KEY:
						thaimode = !thaimode;
						writelanguage( );
						break;

					case F1KEY:
						fontused = 0x00;
						writeattr( );
						break;

					case F2KEY:
						fontused = fontused | ITALICATTR;
						writeattr( );
						break;

					case F3KEY:
						fontused = fontused | ONELINEATTR;
						fontused = fontused & 0x7f;
						writeattr( );
						break;

					case F4KEY:
						fontused = fontused | TWOLINEATTR;
						fontused = fontused & 0xfe;
						writeattr( );
						break;

					case F5KEY:
						fontused = fontused | BOLDATTR;
						writeattr( );
						break;

					case F6KEY:
						fontused = fontused | ENLARGEATTR;
						writeattr( );
						break;

					case F7KEY:
						fontused = fontused | SUPERATTR;
						if ( ( fontused & SUBATTR ) == SUBATTR ) {
							fontused = fontused ^ SUBATTR;
						}
						writeattr( );
						break;

					case F8KEY:
						fontused = fontused | SUBATTR;
						if ( ( fontused & SUPERATTR ) == SUPERATTR ) {
							fontused = fontused ^ SUPERATTR;
						}
						writeattr( );
						break;

					case F9KEY:
						manualwrap( &xCursorPos, &yCursorPos );
						break;

					case ALTM:
						editmacro( );
						break;

					case TABKEY:
					case CNTRL_I:
						movetotab( &xCursorPos, yCursorPos );
						break;

					case CNTRL_K:
						blockcommand( &xCursorPos );
						break;

					case 0x1401:
						blkcmd( 'p', &xCursorPos );
						break;
					case 0x6101:
						blkcmd( 'b', &xCursorPos );
						break;
					case 0x6201:
						blkcmd( 'k', &xCursorPos );
						break;
					case 0x6301:
						blkcmd( 'c', &xCursorPos );
						break;
					case 0x6401:
						blkcmd( 'y', &xCursorPos );
						break;
					case 0x6501:
						blkcmd( 'v', &xCursorPos );
						break;
					case 0x6601:
						blkcmd( 'r', &xCursorPos );
						break;
					case 0x6701:
						blkcmd( 'w', &xCursorPos );
						break;
					case 0x6801:
						blkcmd( 'h', &xCursorPos );
						break;

					case CNTRL_O:
						onscreen( xCursorPos, yCursorPos );
						break;

					case 0x7101:
						doonscrn( 'l', xCursorPos, yCursorPos );
						break;
					case 0x7201:
						doonscrn( 'r', xCursorPos, yCursorPos );
						break;
					case 0x7301:
						doonscrn( 'i', xCursorPos, yCursorPos );
						break;
					case 0x7401:
						doonscrn( 'n', xCursorPos, yCursorPos );
						break;
					case 0x7501:
						doonscrn( 'c', xCursorPos, yCursorPos );
						break;
					case 0x7601:
						doonscrn( 'p', xCursorPos, yCursorPos );
						break;
					case 0x7701:
						doonscrn( 'x', xCursorPos, yCursorPos );
						break;

					case CNTRL_Q:
						quick( &xCursorPos, &yCursorPos );
						break;

					case 0x3501:
						deltoendline( xCursorPos, yCursorPos );
						break;

					case 0x8111:
						inscntrl( CNTRL_W, xCursorPos, yCursorPos );
						break;
					case 0x8211:
						inscntrl( CNTRL_S, xCursorPos, yCursorPos );
						break;
					case 0x8311:
						inscntrl( CNTRL_R, xCursorPos, yCursorPos );
						break;
					case 0x8411:
						inscntrl( CNTRL_B, xCursorPos, yCursorPos );
						break;
					case 0x8511:
						inscntrl( CNTRL_E, xCursorPos, yCursorPos );
						break;
					case 0x8611:
						inscntrl( CNTRL_T, xCursorPos, yCursorPos );
						break;
					case 0x8711:
						inscntrl( CNTRL_V, xCursorPos, yCursorPos );
						break;

					case CNTRL_P:
						printcntrl( xCursorPos, yCursorPos );
						break;

					case HOMEKEY:
						home( &xCursorPos );
						break;

					case ENDKEY:
						endline( &xCursorPos );
						break;

					case CLEKEY:
					case CNTRL_A:
						backword( &xCursorPos );
						break;

					case CRIKEY:
					case CNTRL_F:
						nextword( &xCursorPos, yCursorPos );
						break;

					case CNTRL_L:
						if ( source[0] != '\0' ) {
							if ( replaceflag == NO ) {
								if ( searchfwd( &xCursorPos, &yCursorPos ) == NO ) {
									wordnotfound( );
								}
							} else {
								if ( searchreplace( &xCursorPos, &yCursorPos ) == NO ) {
									wordnotfound( );
								}
							}
						}
						break;

					case CNTRL_B:
						reform( );
						break;

					case ALTP:
						gotopage( );
						break;

					case CNTRL_J:
					case ALTL:
						gotoline( );
						break;

					case 0x5101:
						searching( &xCursorPos, &yCursorPos );
						break;

					case 0x5201:
						replacing( &xCursorPos, &yCursorPos );
						break;

					case 0x8501:
						loadtoline( curline->text );
						refreshline( 0, yCursorPos );
						break;

					case CF1KEY:
						insertmacro( &macro[0][0], &xCursorPos, &yCursorPos );
						break;
					case CF2KEY:
						insertmacro( &macro[1][0], &xCursorPos, &yCursorPos );
						break;
					case CF3KEY:
						insertmacro( &macro[2][0], &xCursorPos, &yCursorPos );
						break;
					case CF4KEY:
						insertmacro( &macro[3][0], &xCursorPos, &yCursorPos );
						break;
					case CF5KEY:
						insertmacro( &macro[4][0], &xCursorPos, &yCursorPos );
						break;
					case CF6KEY:
						insertmacro( &macro[5][0], &xCursorPos, &yCursorPos );
						break;
					case CF7KEY:
						insertmacro( &macro[6][0], &xCursorPos, &yCursorPos );
						break;
					case CF8KEY:
						insertmacro( &macro[7][0], &xCursorPos, &yCursorPos );
						break;
					case CF9KEY:
						insertmacro( &macro[8][0], &xCursorPos, &yCursorPos );
						break;
					case CF10KEY:
						insertmacro( &macro[9][0], &xCursorPos, &yCursorPos );
						break;

					case AF2KEY:
						inscntrl( ITALICCODE, xCursorPos, yCursorPos );
						break;
					case AF3KEY:
						inscntrl( ONELINECODE, xCursorPos, yCursorPos );
						break;
					case AF4KEY:
						inscntrl( TWOLINECODE, xCursorPos, yCursorPos );
						break;
					case AF5KEY:
						inscntrl( BOLDCODE, xCursorPos, yCursorPos );
						break;
					case AF6KEY:
						inscntrl( ENLARGECODE, xCursorPos, yCursorPos );
						break;
					case AF7KEY:
						inscntrl( SUPERCODE, xCursorPos, yCursorPos );
						break;
					case AF8KEY:
						inscntrl( SUBCODE, xCursorPos, yCursorPos );
						break;

#ifdef WANT_TO_USE_GRAPH
					case ALTG:
						insertgraph( );
						break;
					case ALTD:
						deletegraph( );
						break;
#endif

					case ALTX:
						quitprog = YES;
						keymain = ESCKEY;
						break;

					default:
						if ( ( alt_char_map( keymain ) ) != -1 ) {
							keymain = alt_char_map( keymain );
							if ( insertmode ) {
								if ( !insert_char( keymain, &xCursorPos, &yCursorPos ) ) {
									linetoolong( );
								}
							} else {
								if ( !ovrwrite_char( keymain, &xCursorPos, &yCursorPos ) ) {
									linetoolong( );
								}
							}
							refreshline( xCursorPos, yCursorPos );
						}
						break;
					} /* switch ( keymain ) */
				}
				adjustcol( &xCursorPos );
				while ( ( yCursorPos = findrow( ) ) > ( wind.width - 1 ) ) {
					storeline( curline );
					curline = curline->previous;
					loadtoline( curline->text );
					lineno--;
				}
				if ( !keypressed( ) ) {
					if ( !pagecomplete ) {
						showpage( );
					}
					if ( !keypressed( ) ) {
						writecolno( firstcol + xCursorPos );
						dispstrhgc( "   ", wind.col, 2, NORMALATTR );
						if ( !keypressed( ) ) {
							writepageline( );
						}
					}
				}
				if ( quitprog != YES ) {
					waitkbd( wind.col + xCursorPos, wind.row + yCursorPos );
					keymain = readkbd( );
					dispkey( keymain );
				}
			}	/* while */
		} else {	/* if filename[0] != '\0' */
			errorsound( );
		}
	} while ( !quitprog );

	if ( changeflag ) {

		blockmsg( 5 );
		dispstrhgc( "ÂѧäÁèä´é¨Ñ´à¡çºá¿éÁ¢éÍÁÙÅ µéͧ¡ÒèѴà¡çºËÃ×ÍäÁè (Y/N)?", ( 16 + center_factor ) + 7, 5, REVERSEATTR );

		keymain = 0;
		while ( ( keymain != 'n' ) && ( keymain != 'N' )
			&& ( keymain != 'y' ) && ( keymain != 'Y' ) ) {
			keymain = ebioskey( 0 ) & 0xff;
			if ( ( keymain == 'y' ) || ( keymain == 'Y' ) ) {
				writeblk( filename, sentinel->next, 0, sentinel->previous, MAXCOL );
			}
		}
	}
	settext( );

	return 0;
}
示例#25
0
int solve() {
	int choice;
	Result person[MAXLENGTH];
	int n;
	int case1 = 0;
	int currentIndex = 0;

	while(1) {
		switch(choice = menu()) {
			case 1:
			printf("You choose option %d\n", choice);
			getStudentInformation(person, &currentIndex);
			printStudentList(person, currentIndex);
			case1 = 1;
			continue;
			case 2:
			printf("You choose option %d\n", choice);
			if(!case1) {
				printf("Please choose case 1 first!\n");
				continue;
			}
			searching(person, currentIndex);
			continue;
			case 3:
			printf("You choose option %d\n", choice);
			if(!case1) {
				printf("Please choose case 1 first!\n");
				continue;
			}
			findScholashipStudent(person, currentIndex);
			printStudentList(person, currentIndex);
			continue;
			case 4:
			printf("You choose option %d\n", choice);
			if(!case1) {
				printf("Please choose case 1 first!\n");
				continue;
			}
			fixGrade(person, currentIndex);
			printStudentList(person, currentIndex);
			continue;
			case 5:
			printf("You choose option %d\n", choice);
			if(!case1) {
				printf("Please choose case 1 first!\n");
				continue;
			}
			deleteStudent(person, &currentIndex);
			printStudentList(person, currentIndex);
			continue;
			case 6:
			printf("You choose option %d\n", choice);
			break;
			default:
			printf("Invalid choice!\n");
			continue;
		}
		break;
	}

	return 0;
}
double lumcline2(struct SunGeometryConstDay *sungeom,
		 struct SunGeometryVarDay *sunVarGeom,
		 struct SunGeometryVarSlope *sunSlopeGeom,
		 struct GridGeometry *gridGeom, unsigned char *horizonpointer)
{
    double s = 0;
    double length;
    int r = 0;

    int lowPos, highPos;
    double timeoffset, horizPos;
    double horizonHeight;

    func = cube;
    sunVarGeom->isShadow = 0;

    if (useShadow()) {
	length = 0;

	if (useHorizonData()) {
	    /* Start is due east, sungeom->timeangle = -pi/2 */
	    /* timeoffset = sungeom->timeAngle+pihalf; */
	    timeoffset = sunVarGeom->sunAzimuthAngle;

	    /*
	       if(timeoffset<0.)
		  timeoffset+=pi2;
	       else if(timeoffset>pi2)
		  timeoffset-=pi2;
	       horizPos = arrayNumInt - timeoffset/horizonInterval;
	     */

	    horizPos = timeoffset / getHorizonInterval();


	    lowPos = (int)horizPos;
	    highPos = lowPos + 1;
	    if (highPos == arrayNumInt) {
		highPos = 0;
	    }
	    horizonHeight = invScale * ((1. -
					 (horizPos -
					  lowPos)) * horizonpointer[lowPos]
					+ (horizPos - lowPos)
					* horizonpointer[highPos]);
	    sunVarGeom->isShadow =
		(horizonHeight > sunVarGeom->solarAltitude);

	    if (!sunVarGeom->isShadow) {
		/* if (z_orig != UNDEFZ) {
		      s = sunSlopeGeom->lum_C31_l
			* cos(-sungeom->timeAngle - sunSlopeGeom->longit_l)
			+ sunSlopeGeom->lum_C33_l;
		   } else {
		     s = sunVarGeom->sinSolarAltitude;
		   }
		 */
		s = sunSlopeGeom->lum_C31_l
			* cos(-sungeom->timeAngle - sunSlopeGeom->longit_l)
			+ sunSlopeGeom->lum_C33_l;	/* Jenco */
	    }

	}			/*  End if useHorizonData() */
	else {
	    while ((r = searching(&length, sunVarGeom, gridGeom)) == 1) {
		if (r == 3)
		    break;	/* no test is needed */
	    }


	    if (r == 2) {
		sunVarGeom->isShadow = 1;	/* shadow */
	    }
	    else {

		/* if (z_orig != UNDEFZ) {
		      s = sunSlopeGeom->lum_C31_l
			* cos(-sungeom->timeAngle - sunSlopeGeom->longit_l)
			+ sunSlopeGeom->lum_C33_l;
		   } else {
		     s = sunVarGeom->sinSolarAltitude;
		   }
		 */
		s = sunSlopeGeom->lum_C31_l
			* cos(-sungeom->timeAngle - sunSlopeGeom->longit_l)
			+ sunSlopeGeom->lum_C33_l;	/* Jenco */
	    }
	}
    }
    else {
	/* if (z_orig != UNDEFZ) {
	     s = sunSlopeGeom->lum_C31_l
		* cos(-sungeom->timeAngle - sunSlopeGeom->longit_l)
		+ sunSlopeGeom->lum_C33_l;
	   } else {
	     s = sunVarGeom->sinSolarAltitude;
	   }
	 */
	s = sunSlopeGeom->lum_C31_l
		* cos(-sungeom->timeAngle - sunSlopeGeom->longit_l)
		+ sunSlopeGeom->lum_C33_l;	/* Jenco */
    }

    /* if (s <= 0) return UNDEFZ; ?? */
    if (s < 0)
	return 0.;

    return (s);
}
示例#27
0
int main(){
  String a = (char *)malloc(100);
  String b = (char *)malloc(100);
  String d = (char *)malloc(100);
  String e = (char *)malloc(100);
  int c;
  Vertex t = vertex_empty();/* 変数を入力*/
  scanf("%99s",a);
  scanf("%99s", b);
  t = vertex_insert(a, t);
  t = vertex_insert(b, t);
  /* loading data */
  /* tの初期設定 */
  Vertex m;
  Vertex n;
  while (scanf("%99s", d) != EOF)
    { if (strcmp(d, "quit") == 0)
	break;
      scanf("%99s", e);
      scanf("%d", &c);
      if (vertex_search(d,t) == NULL)
        t = vertex_insert(d, t);
      if (vertex_search(e,t) == NULL)
	t = vertex_insert(e, t);
      m = vertex_search(d, t);
      n = vertex_search(e, t);
      m->adj = edge_cons(c, n, m->adj);
      n->adj = edge_cons(c, m, n->adj);
    }
      /* データをロード */
  Edge S = sort((vertex_search(a, t))->adj);
  if (edge_isempty(S))
    printf("%s", a);
  else
    printf("%s", (S->targetp)->name);
  Vertex U[1000];
  int i = 0;
  for (i = 0; i < 1000; i++)
    U[i] = vertex_empty();
  Vertex p;
  i = 0;
  while (((t->right)->finish == 0) || ((t->left)->finish == 0)){
    p = searching(t);
    p->finish = 1;
    p->distance = edge_search(p, S);
    U[i] = p;
    if (p->distance != 0)
    heap_insert(U, i);
    i = i + 1;
  /* ヒープの作成。 */
      }
  /* dijkstra start */
  i--;
  Vertex w;
  while (i > -1){
    w = U[0];
    heap_delete(U,i);
  /*除外状態にないもので一番始点に近いものをとってくる */
  /* ループ開始 */
    dijkstra(U, w, i);
    w->finish = 2;
    i = i-1;
  /* 始点からの距離を更新 */
  /* 元々の点を消して、新たに距離を更新した点をinsertする */
  /* その際、爪あとをのこしておきたい */
  }  /* 爪あとを元にたどって完成 */
  free_vertex(t);
  free(a);
  free(b);
  free(e);
  free(d);
  Vertex adfw = vertex_empty();
  Edge fawe = edge_empty();
  free(adfw);
  free(fawe);
  return 0;
}