Ejemplo n.º 1
0
int main()
{
    Employee joe = {"Joe", 14, 32, 24.15};
    Employee frank = {"Frank", 15,28,18.27};

    // Print Joe's information
    printInformation(joe);

    std::cout << "\n";

    // Print Frank's information
    printInformation(frank);

    return 0;
}
Ejemplo n.º 2
0
int main()
{
    Company myCompany = {{ 1, 42, 60000.0f }, 5 };

    // Print Joe's information
    printInformation(myCompany);

    std::cout << "\n";

    // Print Frank's information
   // printInformation(frank);

    return 0;
}
Ejemplo n.º 3
0
void NetProcess::SendAircraftTrace(const AircraftTrace& vAircraftTrace)
{
	QByteArray dtaArray;
	dtaArray.resize(sizeof(AircraftTrace));
	QBuffer dtaBuffer(&dtaArray);
	dtaBuffer.open(QIODevice::WriteOnly);
	//ÊäÈëÊý¾Ý
	QDataStream out(&dtaBuffer);
	out.setVersion(QDataStream::Qt_4_6);
	out<<vAircraftTrace;
	dtaBuffer.close();  
	m_pUdpSendTraceSocket = (NULL == m_pUdpSendTraceSocket) ? (new QUdpSocket(this)):m_pUdpSendTraceSocket;
	bool isBind = m_pUdpSendTraceSocket->bind(PublicDataStruct::SENDAIRCRAFTTRACEPORT);
	int bytesWritten = m_pUdpSendTraceSocket->writeDatagram(dtaArray,QHostAddress::LocalHost,PublicDataStruct::SENDAIRCRAFTTRACEPORT);
	printInformation(vAircraftTrace,printAircraftPoint);
	delete m_pUdpSendTraceSocket;
	m_pUdpSendTraceSocket = NULL;
}
Ejemplo n.º 4
0
CMyAI::CMyAI()
{
	p_ai = AI::GetInstance();
	CTranspositionTable::getInstance();

	searcher.flag = CSearchEngine::ALPHA_BETA_ITERATIVE_DEEPENING;
	searcher.heuristic.rateBoard = NULL;
	searcher.heuristic.quickRateBoard = &CHeuristicBase::voronoiRateBoard;

	history.reserve(BOARD_SIZE);
	printInformation();

	for (TPos p = 0; p < BOARD_SIZE; p++)
		for (TMove m = 1; m <= 4; m++){
			int y = p / MAP_SIZE;
			int x = p - y * MAP_SIZE;
			switch (m){
			case DIRECTION_DOWN:
				if (y + 1 < MAP_SIZE)
					moveTable[p][m - 1] = p + MAP_SIZE;
				else
					moveTable[p][m - 1] = BLOCK_OUT_OF_BOARD;
				break;
			case DIRECTION_UP:
				if (y - 1 >= 0)
					moveTable[p][m - 1] = p - MAP_SIZE;
				else
					moveTable[p][m - 1] = BLOCK_OUT_OF_BOARD;
				break;
			case DIRECTION_LEFT:
				if (x - 1 >= 0)
					moveTable[p][m - 1] = p - 1;
				else
					moveTable[p][m - 1] = BLOCK_OUT_OF_BOARD;
				break;
			case DIRECTION_RIGHT:
				if (x + 1 < MAP_SIZE)
					moveTable[p][m - 1] = p + 1;
				else
					moveTable[p][m - 1] = BLOCK_OUT_OF_BOARD;
				break;
			}
		}
}
Ejemplo n.º 5
0
Archivo: monitor.c Proyecto: Tyboon/PFE
int main(int argc, char *argv[])
{
     int current_state = 0;
     int monitor_state = 1; /* polling variator (0) or selector (1) */
     int variator_terminated = 0;
     int selector_terminated = 0;

     if (argc == 8)
     {
          sscanf(argv[1], "%s", parnamebase_variator);
          sscanf(argv[2], "%s", filenamebase_variator);
		  sscanf(argv[3], "%s", parnamebase_selector);
          sscanf(argv[4], "%s", filenamebase_selector);
		  sscanf(argv[5], "%s", parnamebase_monitor);
          sscanf(argv[6], "%s", filenamebase_monitor);
          sscanf(argv[7], "%lf", &poll);
          assert(poll >= 0);
     }
     else
     {
          printf("Monitor - wrong number of arguments:\n");
		  printf("monitor varPar varBase selPar selBase monPar monBase poll\n");
          return (1);
     }

     /* generate file names based on 'filenamebase'*/
     sprintf(var_file_variator, "%svar", filenamebase_variator);
     sprintf(sel_file_variator, "%ssel", filenamebase_variator);
     sprintf(cfg_file_variator, "%scfg", filenamebase_variator);
     sprintf(ini_file_variator, "%sini", filenamebase_variator);
     sprintf(arc_file_variator, "%sarc", filenamebase_variator);
     sprintf(sta_file_variator, "%ssta", filenamebase_variator);
     sprintf(var_file_selector, "%svar", filenamebase_selector);
     sprintf(sel_file_selector, "%ssel", filenamebase_selector);
     sprintf(cfg_file_selector, "%scfg", filenamebase_selector);
     sprintf(ini_file_selector, "%sini", filenamebase_selector);
     sprintf(arc_file_selector, "%sarc", filenamebase_selector);
     sprintf(sta_file_selector, "%ssta", filenamebase_selector);

     /* initialize common parameters */
     alpha = 0;
     mu = 0;
     lambda = 0;
     dimension = 0;

	 /* read and check common parameters (they should be equal)*/
     read_common_parameters(cfg_file_variator);
     read_common_parameters(cfg_file_selector);

	 /* read monitor parameters */
     read_local_parameters();

	 /* seed random generator */
	 srand(seed);
	 
	 /* print information file of monitor */
	 printInformation();

	 for (currentRun = 0 ; currentRun < numberOfRuns; currentRun++ ) {
		if (LOG) printf("currentRun = %d \n",currentRun);
		resetAll();
		for (currentGeneration = 1 ; currentGeneration <= numberOfGenerations; currentGeneration++ ) {
			if (LOG) printf("  currentGeneration = %d \n",currentGeneration);
			while(1) {
				if (read_state(sta_file_variator) == 3) {
					copyVariate();
					write_state(sta_file_selector,3);
					if (LOG) printf("    variation done; selector state 3\n");
					break;
				}
				wait(poll);
			}
			while(1) {
				if (read_state(sta_file_selector) == 2) {
					copyArchiveSelected();
					appendOutput();
					write_state(sta_file_variator, 2);
					if (LOG) printf("    selection done; variator state 2\n");
					break;
				};
				wait(poll);
			}
		}
	 }

	 if (LOG) printf("selector state 6 (kill)\n");
	 write_state(sta_file_selector, 6);
	 while(1) {
		 if (read_state(sta_file_selector) == 7) {
			 if (LOG) printf("selector killed\n");
			 break;
		 }
		 wait(poll);
	 }

	 while(1) {
		 if (read_state(sta_file_variator) == 3) {
			 if (LOG) printf("variator state 4 (kill)\n");
			 write_state(sta_file_variator, 4);
			 break;
		 }
		 wait(poll);
	 }
	 while(1) {
		 if (read_state(sta_file_variator) == 5) {
			 if (LOG) printf("variator killed\n");
			 break;
		 }
		 wait(poll);
	 }

	 if (LOG) printf("kill myself\n");
     return (0);
}