예제 #1
0
int main (void) {
    
    string name = GetString();
    
    if (name != NULL) {
        
        int numNames = CountNames(name);
        
        FindInitials(name, numNames);
        
        return 0;
    }
    else {
        main();
    }
}
예제 #2
0
파일: doc_basic.cpp 프로젝트: andoma/pdfium
static int CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
  if (nLevel > nMaxRecursion) {
    return 0;
  }
  CPDF_Array* pNames = pNode->GetArrayBy("Names");
  if (pNames) {
    return pNames->GetCount() / 2;
  }
  CPDF_Array* pKids = pNode->GetArrayBy("Kids");
  if (!pKids) {
    return 0;
  }
  int nCount = 0;
  for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
    CPDF_Dictionary* pKid = pKids->GetDictAt(i);
    if (!pKid) {
      continue;
    }
    nCount += CountNames(pKid, nLevel + 1);
  }
  return nCount;
}
예제 #3
0
파일: world.cpp 프로젝트: nedbrek/Atlantis
void Game::CreateWorld()
{
	int nx = 0;
	int ny = 1;
	if(Globals->MULTI_HEX_NEXUS) {
		ny = 2;
		while(nx <= 0) {
			Awrite("How many hexes should the nexus region be?");
			nx = Agetint();
			if (nx == 1) ny = 1;
			else if (nx % 2) {
				nx = 0;
				Awrite("The width must be a multiple of 2.");
			}
		}
	} else {
		nx = 1;
	}

    int xx = 0;
    while (xx <= 0) {
        Awrite("How wide should the map be? ");
        xx = Agetint();
        if( xx % 8 ) {
            xx = 0;
            Awrite( "The width must be a multiple of 8." );
        }
    }
    int yy = 0;
    while (yy <= 0) {
        Awrite("How tall should the map be? ");
        yy = Agetint();
        if( yy % 8 ) {
            yy = 0;
            Awrite( "The height must be a multiple of 8." );
        }
    }

	regions.CreateLevels(2 + Globals->UNDERWORLD_LEVELS +
			Globals->UNDERDEEP_LEVELS + Globals->ABYSS_LEVEL);

    SetupNames();

	// Leave the Nexus level in even if we're not going to use it;
	// It makes the main body of code more general
	regions.CreateNexusLevel( 0, nx, ny, "nexus" );
    regions.CreateSurfaceLevel( 1, xx, yy, 0 );

    // Create underworld levels
	int i;
	for(i = 2; i < Globals->UNDERWORLD_LEVELS+2; i++) {
		int xs = regions.GetLevelXScale(i);
		int ys = regions.GetLevelYScale(i);
		regions.CreateUnderworldLevel(i, xx/xs, yy/ys, "underworld");
	}
	// Underdeep levels
	for(i=Globals->UNDERWORLD_LEVELS+2;
			i<(Globals->UNDERWORLD_LEVELS+Globals->UNDERDEEP_LEVELS+2); i++) {
		int xs = regions.GetLevelXScale(i);
		int ys = regions.GetLevelYScale(i);
		regions.CreateUnderdeepLevel(i, xx/xs, yy/ys, "underdeep");
	}

	if(Globals->ABYSS_LEVEL) {
		regions.CreateAbyssLevel(Globals->UNDERWORLD_LEVELS +
				Globals->UNDERDEEP_LEVELS + 2, "abyss");
	}

	CountNames();

	if(Globals->UNDERWORLD_LEVELS+Globals->UNDERDEEP_LEVELS == 1) {
		regions.MakeShaftLinks( 2, 1, 8 );
	} else if(Globals->UNDERWORLD_LEVELS+Globals->UNDERDEEP_LEVELS) {
		int i, ii;
		// shafts from surface to underworld
		regions.MakeShaftLinks(2, 1, 10);
		for(i=3; i<Globals->UNDERWORLD_LEVELS+2; i++) {
			regions.MakeShaftLinks(i, 1, 10*i-10);
		}
		// Shafts from underworld to underworld
		if(Globals->UNDERWORLD_LEVELS > 1) {
			for(i = 3; i < Globals->UNDERWORLD_LEVELS+2; i++) {
				for(ii = 2; ii < i; ii++) {
					if(i == ii+1) {
						regions.MakeShaftLinks(i, ii, 12);
					} else {
						regions.MakeShaftLinks(i, ii, 24);
					}
				}
			}
		}
		// underdeeps to underworld
		if(Globals->UNDERDEEP_LEVELS && Globals->UNDERWORLD_LEVELS) {
			// Connect the topmost of the underdeep to the bottommost
			// underworld
			regions.MakeShaftLinks(Globals->UNDERWORLD_LEVELS+2,
					Globals->UNDERWORLD_LEVELS+1, 12);
		}
		// Now, connect the underdeep levels together
		if(Globals->UNDERDEEP_LEVELS > 1) {
			for(i = Globals->UNDERWORLD_LEVELS+3;
					i < Globals->UNDERWORLD_LEVELS+Globals->UNDERDEEP_LEVELS+2;
					i++) {
				for(ii = Globals->UNDERWORLD_LEVELS+2; ii < i; ii++) {
					if(i == ii+1) {
						regions.MakeShaftLinks(i, ii, 12);
					} else {
						regions.MakeShaftLinks(i, ii, 25);
					}
				}
			}
		}
	}

    // We can leave this one - it sets the starting cities
    if (Globals->NEXUS_EXISTS)
        regions.SetACNeighbors( 0, 1, xx, yy );

    regions.InitSetupGates( 1 );
	// Set up gates on all levels of the underworld
	for(int i=2; i < Globals->UNDERWORLD_LEVELS+2; i++) {
		regions.InitSetupGates( i );
	}
	// Underdeep has no gates, only the possible shafts above.

    regions.FinalSetupGates();

    regions.CalcDensities();
}
예제 #4
0
	AddChild(inMenuBar);

	ReplaceContent(inContent);
}


void
BafxWindow::MessageReceived(BMessage* message)
{
	DEBUG_PRINT(("%s:message:%c%c%c%c\n",
		__FUNCTION__,
		message->what>>24,
		message->what>>16,
		message->what>>8,
		message->what));
	DEBUG_PRINT(("CountNames: %d\n", message->CountNames(B_ANY_TYPE)));

	switch(message->what)
	{
	default:
		BWindow::MessageReceived(message);
		break;
	}
}


void
BafxWindow::Quit (void)
{
	be_app->PostMessage(B_QUIT_REQUESTED, be_app);
	BWindow::Quit();