当前位置: 首页>>代码示例>>C++>>正文


C++ printf_s函数代码示例

本文整理汇总了C++中printf_s函数的典型用法代码示例。如果您正苦于以下问题:C++ printf_s函数的具体用法?C++ printf_s怎么用?C++ printf_s使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printf_s函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: puts

void NetworkManager::GameRun()
{
	PacketType type;

	Network::GameStartData gameStartData;
	puts("게임 시작 대기중");
	network.WaitForStart(&gameStartData);
	wprintf_s(L"매칭되었습니다. 상대방 이름: %s, 학번: %d\n", gameStartData.oppositionName, gameStartData.oppositionStudentID);

	bool allOver = false;

	while (!allOver)
	{
		
		GameInit();
		ShipSetting();

		try
		{
			GameStart();
			network.GetPacketType(&type);

			if (type == PKT_SC_NEXT_GAME)
			{
				puts("다음 게임을 준비해주세요.");
				
			}
			else if (type == PKT_SC_ALL_OVER)
			{
				Network::FinalResultData finalresult;
				finalresult = network.GetFinalResult();
				puts("모두 종료");
				printf_s("승리 횟수: %d, 평균 턴 수: %.1f", finalresult.winCount, finalresult.avgTurns);

				allOver = true;
			}
			else
			{
				throw Network::UNEXPECTED_PACKET;
			}
		}
		catch (Network::Exception ex)
		{
			switch (ex)
			{
			case Network::NETWORK_ERROR:
				puts("네트워크에 문제가 발생했습니다.");
				break;
			case Network::SERVER_CLOSED:
				puts("서버와의 연결이 끊어졌습니다.");
				break;
			case Network::PARAMETER_ERROR:
				puts("함수의 인수가 잘못되었습니다.");
				break;
			case Network::UNEXPECTED_PACKET:
				puts("서버에서 잘못된 정보가 전송되었습니다.");
				break;
			default:
				break;
			}
		}
		
	}
}
开发者ID:yelimlim,项目名称:battleship,代码行数:64,代码来源:NetworkManager.cpp

示例2: main


//.........这里部分代码省略.........
				throw err_code;
			for (n = 0; n < num_comps; n++)
			{
				io_byte *src = line + n; // Points to first sample of component n
				float *dst = input_comps[n].buf + r * input_comps[n].stride;
				for (int c = 0; c < width; c++, src += num_comps)
					dst[c] = (float)*src; // The cast to type "float" is not
						  // strictly required here, since bytes can always be
						  // converted to floats without any loss of information.
			}
		}
		delete[] line;
		bmp_in__close(&in);

		// Allocate storage for the filtered output
		my_aligned_image_comp *output_comps =
			new my_aligned_image_comp[num_comps];

		for (n = 0; n < num_comps; n++) {
			output_comps[n].init(out_size, out_size, 0); // Don't need a border for output
		}

		  // Process the image, all in floating point (easy)
		for (n = 0; n < num_comps; n++) {
			input_comps[n].perform_boundary_extension();
		}

		for (int k = 0; k < num_comps; ++k)
			for (int i = -half_outsize; i < half_outsize; ++i)
				for (int j = -half_outsize; j < half_outsize; ++j) {
					output_comps[k].buf[(i+ half_outsize) * output_comps[k].stride + (j+ half_outsize)]
						= input_comps[k].buf[i * input_comps[k].stride + j 
						+ location_x + location_y * input_comps[k].stride];
				}

		for (n = 0; n < num_comps; n++) {
			output_comps[n].mean_substract();
			output_comps[n].hanning_window();
		}

		
		// Write the image back out again
		bmp_out out;
		io_byte *out_line = new io_byte[out_size*num_comps];
		if ((err_code = bmp_out__open(&out, argv[2], out_size, out_size, num_comps)) != 0)
			throw err_code;
		for (r = out_size - 1; r >= 0; r--)
		{ // "r" holds the true row index we are writing, since the image is
		  // written upside down in BMP files.
			for (n = 0; n < num_comps; n++)
			{
				io_byte *dst = out_line + n; // Points to first sample of component n
				float *src = output_comps[n].buf + r * output_comps[n].stride;
				for (int c = 0; c < out_size; c++, dst += num_comps) {
					
					if (src[c] > 255) {
						src[c] = 255;
					}
					else if (src[c] < 0) {
						src[c] = 0;
					}
						
					*dst = (io_byte)src[c];
				}
			}
			bmp_out__put_line(&out, out_line);
		}
		bmp_out__close(&out);
		delete[]out_line;
		delete[] input_comps;
		delete[] output_comps;

		clock_t end_time = clock();
		float elaps = ((float)(end_time - start_time)) / CLOCKS_PER_SEC;
		printf_s("The runtime is %f seconds!\n\r", elaps);
		system("Pause");

	}
	catch (int exc) {
		if (exc == IO_ERR_NO_FILE)
			fprintf(stderr, "Cannot open supplied input or output file.\n");
		else if (exc == IO_ERR_FILE_HEADER)
			fprintf(stderr, "Error encountered while parsing BMP file header.\n");
		else if (exc == IO_ERR_UNSUPPORTED)
			fprintf(stderr, "Input uses an unsupported BMP file format.\n  Current "
				"simple example supports only 8-bit and 24-bit data.\n");
		else if (exc == IO_ERR_FILE_TRUNC)
			fprintf(stderr, "Input or output file truncated unexpectedly.\n");
		else if (exc == IO_ERR_FILE_NOT_OPEN)
			fprintf(stderr, "Trying to access a file which is not open!(?)\n");
		else if (exc == X_ECCESS)
			fprintf(stderr, "The given location eccess x dimension!\n");
		else if (exc == Y_ECCESS)
			fprintf(stderr, "The given location eccess y dimension!\n");
		else if (exc == NOT_A_EVEN_NUMBER)
			fprintf(stderr, "The given output dimension is not a odd number!\n");
		return -1;
	}
	return 0;
}
开发者ID:ZhenningUNSW,项目名称:ELEC4622_s2_2015_UNSW,代码行数:101,代码来源:hanningextraction_main.cpp

示例3: main

int main() {
	TList *list = new TList();
	printf_s("list.First() = %s\n", list->First());
	printf_s("list.Pop() = %s\n", list->Pop());

	list->Push("Hola");
	printf_s("Pushed \"Hola\"!\n");
	list->Push("Holita");
	printf_s("Pushed \"Holita\"!\n");
	list->Push("Que tal?");
	printf_s("Pushed \"Que tal?\"!\n");

	printf_s("list.Next() = %s\n", list->Next());
	printf_s("list.Next() = %s\n", list->Next());
	printf_s("list.Next() = %s\n", list->Next());
	printf_s("list.Next() = %s\n", list->Next());

	printf_s("list.First() = %s\n", list->First());
	printf_s("list.Pop() = %s\n", list->Pop());
	printf_s("list.First() = %s\n", list->First());

	list->Push("Hola");

	list->Reset();
	printf_s("list reset!\n");

	printf_s("list.First() = %s\n", list->First());
	printf_s("list.Next() = %s\n", list->Next());

	delete list;

	getchar();
}
开发者ID:jjimenezg93,项目名称:CPP_programming,代码行数:33,代码来源:main.cpp

示例4: SetColor

bool GameInterface::GameStartOrReset()
{
	bool startOrReset = true;
	int gotoX = (m_MapSize + 3) * 4 + 4;
	int gotoY = 7;
	SetColor(BLACK, GREEN);
	SetCursorPosition(gotoX + 2, gotoY + 12);
	printf_s("                  \n");
	SetCursorPosition(gotoX + 2, gotoY + 13);
	printf_s("    Start Game    \n");
	SetCursorPosition(gotoX + 2, gotoY + 14);
	printf_s("                  \n");
	SetColor(BLACK, WHITE);
	SetCursorPosition(gotoX + 2, gotoY + 17);
	printf_s("                  \n");
	SetCursorPosition(gotoX + 2, gotoY + 18);
	printf_s("       Reset      \n");
	SetCursorPosition(gotoX + 2, gotoY + 19);
	printf_s("                  ");
	while (true)
	{
		int keyinput;
		keyinput = _getch();
		if (keyinput == -32)
		{
			keyinput = _getch();
		}
		if (keyinput == KEY_DOWN && startOrReset == true)
		{
			SetColor(BLACK, WHITE);
			SetCursorPosition(gotoX + 2, gotoY + 12);
			printf_s("                  \n");
			SetCursorPosition(gotoX + 2, gotoY + 13);
			printf_s("    Start Game    \n");
			SetCursorPosition(gotoX + 2, gotoY + 14);
			printf_s("                  \n");
			SetColor(BLACK, DARK_RED);
			SetCursorPosition(gotoX + 2, gotoY + 17);
			printf_s("                  \n");
			SetCursorPosition(gotoX + 2, gotoY + 18);
			printf_s("       Reset      \n");
			SetCursorPosition(gotoX + 2, gotoY + 19);
			printf_s("                  ");
			startOrReset = false; //Reset
		}
		else if (keyinput == KEY_UP && startOrReset == false)
		{
			SetColor(BLACK, GREEN);
			SetCursorPosition(gotoX + 2, gotoY + 12);
			printf_s("                  \n");
			SetCursorPosition(gotoX + 2, gotoY + 13);
			printf_s("    Start Game    \n");
			SetCursorPosition(gotoX + 2, gotoY + 14);
			printf_s("                  \n");
			SetColor(BLACK, WHITE);
			SetCursorPosition(gotoX + 2, gotoY + 17);
			printf_s("                  \n");
			SetCursorPosition(gotoX + 2, gotoY + 18);
			printf_s("       Reset      \n");
			SetCursorPosition(gotoX + 2, gotoY + 19);
			printf_s("                  ");
			startOrReset = true; //Start
		}
		else if (keyinput == ENTER)
		{
			break;
		}
	}
	SetColor(WHITE, BLACK);
	return startOrReset;
}
开发者ID:WooJaeWoo,项目名称:Smith_CPP,代码行数:71,代码来源:GameInterface.cpp

示例5: switch

// SET METHODS //
void Card::SetRank(int rank)
{
    // Set m_iFaceValue based upon "rank", and RANK as well. (A == 1 ... K == 13)
    switch (rank)
    {
    case 1:
        m_iFaceValue = rank;
        m_eRank = RANK::ACE;
        break;
    case 2:
        m_iFaceValue = rank;
        m_eRank = RANK::TWO;
        break;
    case 3:
        m_iFaceValue = rank;
        m_eRank = RANK::THREE;
        break;
    case 4:
        m_iFaceValue = rank;
        m_eRank = RANK::FOUR;
        break;
    case 5:
        m_iFaceValue = rank;
        m_eRank = RANK::FIVE;
        break;
    case 6:
        m_iFaceValue = rank;
        m_eRank = RANK::SIX;
        break;
    case 7:
        m_iFaceValue = rank;
        m_eRank = RANK::SEVEN;
        break;
    case 8:
        m_iFaceValue = rank;
        m_eRank = RANK::EIGHT;
        break;
    case 9:
        m_iFaceValue = rank;
        m_eRank = RANK::NINE;
        break;
    case 10:
        m_iFaceValue = rank;
        m_eRank = RANK::TEN;
        break;
    case 11:
        m_iFaceValue = rank;
        m_eRank = RANK::JACK;
        break;
    case 12:
        m_iFaceValue = rank;
        m_eRank = RANK::QUEEN;
        break;
    case 13:
        m_iFaceValue = rank;
        m_eRank = RANK::KING;
        break;
    default:
        m_iFaceValue = 1;
        m_eRank = RANK::ACE;
        // Throw a message here stating we did not get the appropriate card set up correctly
        printf_s("Card's RANK was not set correctly, rank VALUE: %d", rank);
        break;
    };
}
开发者ID:ChrisC64,项目名称:FiveCardDraw_UWP_App,代码行数:66,代码来源:Card.cpp

示例6: while

int GameInterface::MenuSelect(int menuSize, int gotoX, int gotoY, int currentY, GameStatus gameStatus)
{
	int menuSelector = 0;
	bool okToStart = false;
	int sumShips;
	while (true)
	{
		int keyinput;
		keyinput = _getch();
		if (keyinput == -32)
		{
			keyinput = _getch();
		}
		if (keyinput == KEY_DOWN)
		{
			if (gameStatus == SELECT_PLAYER || gameStatus == SET_SHIP)
			{
				if (menuSelector >= 0 && menuSelector < menuSize - 1)
				{
					SetCursorPosition(gotoX, currentY);
					printf_s("  ");
					currentY += 3;
					menuSelector += 1;
					SetCursorPosition(gotoX, currentY);
					printf_s("¢º");
				}
			}
			else if (gameStatus == SELECT_MAP_SHIP)
			{
				if (menuSelector >= 0 && menuSelector < menuSize - 2)
				{
					SetCursorPosition(gotoX, currentY);
					printf_s("  ");
					currentY += 3;
					menuSelector += 1;
					SetCursorPosition(gotoX, currentY);
					printf_s("¢º");
				}
				else if (menuSelector == menuSize - 2)
				{
					sumShips = GetSumShip();
					SetCursorPosition(gotoX, currentY);
					printf_s("  ");
					currentY += 3;
					menuSelector += 1;
					if (sumShips == 0)
					{
						okToStart = false;
						SetColor(BLACK, DARK_RED);
						SetCursorPosition(gotoX + 18, gotoY + 20);
						printf_s("                   \n");
						SetCursorPosition(gotoX + 18, gotoY + 21);
						printf_s("      No Ship      \n");
						SetCursorPosition(gotoX + 18, gotoY + 22);
						printf_s("                   ");
					}
					else if (CheckEnoughSize() == false)
					{
						okToStart = false;
						SetColor(BLACK, DARK_RED);
						SetCursorPosition(gotoX + 18, gotoY + 20);
						printf_s("                   \n");
						SetCursorPosition(gotoX + 18, gotoY + 21);
						printf_s("   Too Many Ships  \n");
						SetCursorPosition(gotoX + 18, gotoY + 22);
						printf_s("                   ");
					}
					else
					{
						okToStart = true;
						SetColor(BLACK, GREEN);
						SetCursorPosition(gotoX + 18, gotoY + 20);
						printf_s("                   \n");
						SetCursorPosition(gotoX + 18, gotoY + 21);
						printf_s("      N E X T      \n");
						SetCursorPosition(gotoX + 18, gotoY + 22);
						printf_s("                   ");
					}
				}
			}
		}
		else if (keyinput == KEY_UP)
		{
			if (gameStatus == SELECT_PLAYER || gameStatus == SET_SHIP)
			{
				if (menuSelector >= 1 && menuSelector < menuSize)
				{
					SetCursorPosition(gotoX, currentY);
					printf_s("  ");
					currentY -= 3;
					menuSelector -= 1;
					SetCursorPosition(gotoX, currentY);
					printf_s("¢º");
				}
			}
			else if (gameStatus == SELECT_MAP_SHIP)
			{
				if (menuSelector >= 1 && menuSelector < menuSize - 1)
				{
					SetCursorPosition(gotoX, currentY);
//.........这里部分代码省略.........
开发者ID:WooJaeWoo,项目名称:Smith_CPP,代码行数:101,代码来源:GameInterface.cpp

示例7: setState

void TurnstileGate::Unlock()
{
	setState(unlocked);
	printf_s("Unlocked\n\n");
}
开发者ID:lolobster,项目名称:AI-TestProjects,代码行数:5,代码来源:TurnstileGate.cpp

示例8: printf_s

void TurnstileGate::Thankyou()
{
	printf_s("Thanks!\n\n");
}
开发者ID:lolobster,项目名称:AI-TestProjects,代码行数:4,代码来源:TurnstileGate.cpp

示例9: printf_s

void CClientUdpSocket::Run()
{
	int nPacketCount = 1;
	m_blRun = true;
	SOCKET sckClient;
	SOCKET sckServer;

	//此部分为兼容Lua参数而设计
	//为了减少不必要的new和delete操作,所以参数在这里先声明好
	_ParamData* pSendParam1   = NULL;
	_ParamData* pSendParam2   = NULL;
	_ParamData* pSendParam3   = NULL;
	_ParamData* pSendParam4   = NULL;
	_ParamData* pSendParamOut = NULL;
	_ParamData* pRecvParam1   = NULL;
	_ParamData* pRecvParam2   = NULL;
	_ParamData* pRecvParam3   = NULL;
	_ParamData* pRecvParam4   = NULL;
	_ParamData* pRecvParamOut = NULL;

	int nLuaBufferMaxLength = m_pSocket_Info->m_pLogic->GetSendLength();

	if(m_pSocket_Info == NULL || m_pSocket_State_Info == NULL)
	{
		m_blRun = false;
		return;
	}

	//如果是高级模式
	if(m_pSocket_Info->m_blLuaAdvance == true)
	{
		m_objLuaFn.InitClass();

		bool blState = m_objLuaFn.LoadLuaFile(m_pSocket_Info->m_szLuaFileName);
		if(false == blState)
		{
			printf_s("[Main]Open Lua file error.\n");
			return;
		}

		//初始化所有要使用的Lua参数
		pSendParam1   = new _ParamData();
		pSendParam2   = new _ParamData();
		pSendParam3   = new _ParamData();
		pSendParam4   = new _ParamData();
		pSendParamOut = new _ParamData();
		pRecvParam1   = new _ParamData();
		pRecvParam2   = new _ParamData();
		pRecvParam3   = new _ParamData();
		pRecvParam4   = new _ParamData();
		pRecvParamOut = new _ParamData(); 

	}

	//看看是否是长连接,如果是长连接,则只处理一次。
	bool blIsConnect = false;

	//socket创建的准备工作
	struct sockaddr_in svrsockaddr;

	memset(&svrsockaddr, 0, sizeof(SOCKADDR_IN));
	svrsockaddr.sin_family = AF_INET;
	svrsockaddr.sin_port   = htons(m_pSocket_Info->m_nPort);
	svrsockaddr.sin_addr.S_un.S_addr = inet_addr(m_pSocket_Info->m_szSerevrIP);

	sckClient = socket(AF_INET, SOCK_DGRAM, 0);

	DWORD TimeOut = (DWORD)m_pSocket_Info->m_nRecvTimeout;
	::setsockopt(sckClient, SOL_SOCKET, SO_RCVTIMEO, (char *)&TimeOut, sizeof(TimeOut));

	//设置接收监听端口
	sckServer = socket(AF_INET, SOCK_DGRAM, 0);

	struct sockaddr_in clientsockaddr;
	memset(&clientsockaddr, 0, sizeof(SOCKADDR_IN));
	clientsockaddr.sin_family = AF_INET;
	clientsockaddr.sin_port   = htons(m_pSocket_Info->m_nUdpClientPort);
	clientsockaddr.sin_addr.S_un.S_addr = inet_addr(m_pSocket_Info->m_szSerevrIP);

	bind(sckServer, (SOCKADDR *) &clientsockaddr, sizeof(clientsockaddr));

	//发送次数
	int nSendIndex = 0;

	while(m_blRun)
	{
		unsigned int tBegin = (unsigned int)GetTickCount();
		if(m_pSocket_Info->m_nSendCount != 0 && m_pSocket_State_Info->m_nSuccessSend >= m_pSocket_Info->m_nSendCount)
		{
			//发送指定数目的数据包完成
			break;
		}

		//查看是否开启高级模式
		if(m_pSocket_Info->m_blLuaAdvance == true)
		{
			//重置缓冲最大长度
			m_pSocket_Info->m_pLogic->SetMaxSendLength(nLuaBufferMaxLength);

			//开始调用Lua脚本,去组织数据块
//.........这里部分代码省略.........
开发者ID:0328shijian,项目名称:PSS,代码行数:101,代码来源:ClientUdpSocket.cpp

示例10: printf_s

void NPC::Dead()
{
	printf_s("NPC is Dead!! \n");
}
开发者ID:agebreak,项目名称:NEXT_CPP_Learning,代码行数:4,代码来源:NPC.cpp

示例11: CoCreateInstance

// 初始化语音识别
HRESULT ThisApp::init_speech_recognizer(){
    HRESULT hr = S_OK;
    // 创建语音输入流
    if (SUCCEEDED(hr)){
        hr = CoCreateInstance(CLSID_SpStream, nullptr, CLSCTX_INPROC_SERVER, __uuidof(ISpStream), (void**)&m_pSpeechStream);;
    }
    // 与我们的Kinect语音输入相连接
    if (SUCCEEDED(hr)){
        WAVEFORMATEX wft = {
            WAVE_FORMAT_PCM, // PCM编码
            1, // 单声道
            16000,  // 采样率为16KHz
            32000, // 每分钟数据流 = 采样率 * 对齐
            2, // 对齐 : 单声道 * 样本深度 = 2byte
            16, // 样本深度 16BIT
            0 // 额外数据
        };
        // 设置状态
        hr = m_pSpeechStream->SetBaseStream(m_p16BitPCMAudioStream, SPDFID_WaveFormatEx, &wft);
    }
    // 创建语音识别对象
    if (SUCCEEDED(hr)){
        ISpObjectToken *pEngineToken = nullptr;
        // 创建语言识别器
        hr = CoCreateInstance(CLSID_SpInprocRecognizer, nullptr, CLSCTX_INPROC_SERVER, __uuidof(ISpRecognizer), (void**)&m_pSpeechRecognizer);
        if (SUCCEEDED(hr)) {
            // 连接我们创建的语音输入流对象
            m_pSpeechRecognizer->SetInput(m_pSpeechStream, TRUE);
            // 创建待识别语言 这里选择大陆汉语(zh-cn) 
            // 目前没有Kinect的汉语语音识别包 有的话可以设置"language=804;Kinect=Ture"
            hr = SpFindBestToken(SPCAT_RECOGNIZERS, L"Language=804", nullptr, &pEngineToken);
            if (SUCCEEDED(hr)) {
                // 设置待识别语言
                m_pSpeechRecognizer->SetRecognizer(pEngineToken);
                // 创建语音识别上下文
                hr = m_pSpeechRecognizer->CreateRecoContext(&m_pSpeechContext);
                // 适应性 ON! 防止因长时间的处理而导致识别能力的退化
                if (SUCCEEDED(hr))  {
                    hr = m_pSpeechRecognizer->SetPropertyNum(L"AdaptationOn", 0);
                }
            }
        }
        SafeRelease(pEngineToken);
    }
    // 创建语法
    if (SUCCEEDED(hr)){
        hr = m_pSpeechContext->CreateGrammar(1, &m_pSpeechGrammar);
    }
    // 加载静态SRGS语法文件
    if (SUCCEEDED(hr)){
        hr = m_pSpeechGrammar->LoadCmdFromFile(s_GrammarFileName, SPLO_STATIC);
    }
    // 激活语法规则
    if (SUCCEEDED(hr)){
        hr = m_pSpeechGrammar->SetRuleState(nullptr, nullptr, SPRS_ACTIVE);
    }
    // 设置识别器一直读取数据
    if (SUCCEEDED(hr)){
        hr = m_pSpeechRecognizer->SetRecoState(SPRST_ACTIVE_ALWAYS);
    }
    // 设置对识别事件感兴趣
    if (SUCCEEDED(hr)){
        hr = m_pSpeechContext->SetInterest(SPFEI(SPEI_RECOGNITION), SPFEI(SPEI_RECOGNITION));
    }
    // 保证语音识别处于激活状态
    if (SUCCEEDED(hr)){
        hr = m_pSpeechContext->Resume(0);
    }
    // 获取识别事件
    if (SUCCEEDED(hr)){
        m_p16BitPCMAudioStream->SetSpeechState(TRUE);
        m_hSpeechEvent = m_pSpeechContext->GetNotifyEventHandle();
		printf_s("init_speech_recognizer succeeded\n");
    }
#ifdef _DEBUG
    else
        printf_s("init_speech_recognizer failed\n");
#endif
    return hr;
}
开发者ID:HYY66,项目名称:Kinect2.0-1,代码行数:81,代码来源:ThisApp.cpp

示例12: while

void NetworkManager::GameStart()
{
	PacketType type;
	ErrorType error;
	bool gameOver = false;

	Position attackpos;
	Position hitpos;

	while (!gameOver)
	{
		error = network.GetPacketType(&type);

		switch (type)
		{
		case PKT_SC_ERROR:
			if (error == ET_OPPOSITION_DISCONNECTED)
				puts("상대방의 접속이 끊어졌습니다.");
			else
				puts("알 수 없는 에러입니다.");
			return;
			break;
		case PKT_SC_MY_TURN:
		{
			while (true)
			{
				if (m_player->GetType() == Ai)
				{
					AI* ai = (AI*)m_player;
					attackpos = ai->AttackShip();
				}
				else
				{
					attackpos = m_player->AttackShip();
				}

				printf_s("%c%c\n", attackpos.x, attackpos.y);

				error = network.SubmitAttack(PositionToCoord(attackpos));

				if (error == ET_INVALID_ATTACK)
					puts("유효하지 않은 공격 위치입니다.");
				else
					break;
			}
		}
			break;
		case PKT_SC_ATTACK_RESULT:
		{
			Network::AttackResultData result;
			result = network.GetAttackResult();
			if (result.isMine)
			{
				puts("공격 결과:");

				printf_s("%c%c ", result.pos.mX + 'a', result.pos.mY + '1');

				switch (result.attackResult)
				{
				case AR_DESTROY_AIRCRAFT:
					printf_s("Result: DESTROY_AIRCRAFT\n");
					break;
				case AR_DESTROY_BATTLESHIP:
					printf_s("Result: DESTROY_BATTLESHIP\n");
					break;
				case AR_DESTROY_CRUISER:
					printf_s("Result: DESTROY_CRUISER\n");
					break;
				case AR_DESTROY_DESTROYER:
					printf_s("Result: DESTROY_DESTROYER\n");
					break;
				case AR_HIT:
					printf_s("Result: HIT");
					break;
				case AR_MISS:
					printf_s("Result: MISS");
					break;

				}


				if (m_player->GetType() == Ai)
				{
					AI* ai = (AI*)m_player;
					ai->TakeAttackResult(attackpos, result.attackResult);
				}
				else
				{
					m_player->TakeAttackResult(attackpos, result.attackResult);
				}

			}
			else
			{
				puts("피격 결과:");
				hitpos.x = result.pos.mX + 'a';
				hitpos.y = result.pos.mY + '1';

				m_player->HitCheck(hitpos);
				printf_s("%c%c", hitpos.x, hitpos.y);
//.........这里部分代码省略.........
开发者ID:yelimlim,项目名称:battleship,代码行数:101,代码来源:NetworkManager.cpp

示例13: main

int main(int argc, char *argv[])
{
	Win32LoadOpenCv();
	
	CvMat *imageLeft = OpenCvImreadM("images/obstacles_0stereo.jpg", CV_LOAD_IMAGE_GRAYSCALE);
	CvMat *imageRight = OpenCvImreadM("images/obstacles_10stereo.jpg", CV_LOAD_IMAGE_GRAYSCALE);
	
	if((imageLeft == 0) || (imageRight == 0))
	{
		printf_s("One or more images failed to load \n");
		return -1;
	}
	
	CvMat *imageDisparity16S = OpenCvCreateMat(imageLeft->rows, imageLeft->cols,
		CV_16S); // CvMat{imageLeft->rows, CV_16S};
	CvMat *imageDisparity8U = OpenCvCreateMat(imageLeft->rows, imageLeft->cols,
		CV_8UC1); // CvMat(imageLeft->rows, CV_8UC1);
	
	int32 disparities = 112;
	CvStereoBMState *stereoBMState = OpenCvCreateStereoBMState(CV_STEREO_BM_BASIC,
		disparities);
	stereoBMState->SADWindowSize = 9;
	stereoBMState->preFilterSize = 5;
	stereoBMState->preFilterCap = 61;
	stereoBMState->minDisparity = -39;
	stereoBMState->textureThreshold = 507;
	stereoBMState->uniquenessRatio = 0;
	stereoBMState->speckleWindowSize = 0;
	stereoBMState->speckleRange = 8;
	stereoBMState->disp12MaxDiff = 1;
	
	for(int i = 1;
		i < 4;
		i = i + 2)
	{
		OpenCvSmooth(imageLeft, imageLeft, CV_BLUR, i, i, 3, 3);
	}
	for(int i = 1;
		i < 4;
		i = i + 2)
	{
		OpenCvSmooth(imageRight, imageRight, CV_BLUR, i, i, 3, 3);
	}
	
	OpenCvFindStereoCorrespondenceBM(imageLeft, imageRight,
			imageDisparity16S, stereoBMState);
		
	double minValue;
	double maxValue;
	OpenCvMinMaxLoc(imageDisparity16S, &minValue, &maxValue, 0, 0, 0);
	
	printf_s("Min disparity: %f - Max disparity: %f \n",
		minValue, maxValue);
		
	OpenCvConvertScale(imageDisparity16S, imageDisparity8U,
		255.0/(maxValue - minValue), 0);
		
	// OpenCvNamedWindow(g_WindowName, CV_WINDOW_AUTOSIZE);
	// OpenCvShowImage(g_WindowName, imageDisparity8U);
	
	OpenCvSaveImage("../matlab/disparityMap.bmp", imageDisparity8U, 0);
	
	OpenCvWaitKey(0);
	
	OpenCvReleaseStereoBMState(&stereoBMState);
	
	return 0;
}
开发者ID:JBrauns,项目名称:ProjektLuna,代码行数:68,代码来源:luna.cpp

示例14: main

int main(int argc, char* argv[])
{
	int infoMago = 0xFFA82000;
	int opcion = 0;
	unsigned int balas = 0;

	do {
		printf_s("MENU DEL PERSONAJE:\n");

		printf_s("Elija una de las siguientes opciones\n");
		printf_s("1. Mostrar número de balas\n");
		printf_s("2. Añadir balas\n");
		printf_s("3. Comprobar si tienes balas infinitas\n");
		printf_s("4. Activar las balas infinitas\n");
		printf_s("5. Salir\n\n");

		scanf_s("%i", &opcion);
		printf_s("\n");


		switch (opcion) {
		case 1:
			printf_s("Balas en el inventario: %d\n", balasInventario(infoMago));
			printf_s("\n");
			break;
		case 2:
			printf_s("Número de balas actual: %u\n", balasInventario(infoMago));
			printf_s("¿Cuántas balas quieres añadir?: ");
			scanf_s("%i", &balas);
			printf_s("\n");
			if (balas > 255) {
				printf_s("El máximo de balas que puedes llevar es 255\n");
			}
			printf_s("Balas en el inventario: %u\n", anadirBalas(infoMago, balas));
			printf_s("\n");
			break;
		case 3:
			if (comprobarBalasInfinitas(infoMago)) {
				printf_s("Tienes balas infinitas\n");
				printf_s("\n");
			}
			else {
				printf_s("No tienes balas infinitas\n");
				printf_s("\n");
			}
			break;
		case 4:
			if (activarBalasInfinitas(infoMago)) {
				printf_s("Ya tienes balas infinitas\n");
				printf_s("\n");
			}
			else {
				printf_s("No tienes balas infinitas\n");
				printf_s("\n");
			}
			break;
		case 5:
			break;
		}
	} while (opcion != 5);
}
开发者ID:JosCamMan,项目名称:Programacion_Cpp,代码行数:61,代码来源:[FINAL]+Practica+1.cpp

示例15: switch

void GameInterface::AttachInterface(GameStatus gameStatus)
{
	int gotoX;
	int gotoY;
	int currentY;
	int menuSelector = 0;
	switch (gameStatus)
	{
	case TITLE:
		gotoX = 0;
		gotoY = 10;
		while (!_kbhit())
		{
			Sleep(600);
			SetCursorPosition(gotoX, gotoY);
			printf_s("\t\t\t     PRESS ENTER KEY TO START      \t\t\t");
			Sleep(1000);
			SetCursorPosition(gotoX, gotoY);
			printf_s("                                                                            ");
		}
		getchar();
		break;
	case SELECT_PLAYER:
		gotoX = 22;
		gotoY = 9;
		currentY = gotoY + 6;
		SetColor(BLACK, WHITE);
		SetCursorPosition(gotoX, gotoY);
		printf_s("                  \n");
		SetCursorPosition(gotoX, gotoY + 1);
		printf_s("   PLAYER SELECT  \n");
		SetCursorPosition(gotoX, gotoY + 2);
		printf_s("                  ");
		SetColor(WHITE, BLACK);
		SetCursorPosition(gotoX + 7, gotoY + 6);
		printf_s("VS Friend");
		SetCursorPosition(gotoX + 7, gotoY + 9);
		printf_s("VS AI");
		SetCursorPosition(gotoX + 7, gotoY + 12);
		printf_s("VS Network");
		SetCursorPosition(gotoX - 1, currentY);
		printf_s("¢º");
		menuSelector = MenuSelect(3, gotoX, gotoY, currentY, gameStatus);
		if (menuSelector == 0)
		{
			m_GameType = PVP_PLAY;
		}
		else if (menuSelector == 1)
		{
			m_GameType = AI_PLAY;
		}
		else if (menuSelector == 2)
		{
			m_GameType = NET_PLAY;
		}
		break;
	case SELECT_MAP_SHIP:
		gotoX = 4;
		gotoY = 9;
		currentY = gotoY + 5;
		SetColor(BLACK, WHITE);
		SetCursorPosition(gotoX + 18, gotoY);
		printf_s("                  \n");
		SetCursorPosition(gotoX + 18, gotoY + 1);
		printf_s("    SHIP SELECT   \n");
		SetCursorPosition(gotoX + 18, gotoY + 2);
		printf_s("                  ");
		SetColor(WHITE, BLACK);
		SetCursorPosition(gotoX + 6, gotoY + 5);
		printf_s("Map size");
		SetCursorPosition(gotoX + 6, gotoY + 8);
		printf_s("Aircraft Carrier");
		SetCursorPosition(gotoX + 6, gotoY + 11);
		printf_s("Battleship");
		SetCursorPosition(gotoX + 6, gotoY + 14);
		printf_s("Cruiser");
		SetCursorPosition(gotoX + 6, gotoY + 17);
		printf_s("Destroyer");
		SetColor(BLACK, WHITE);
		SetCursorPosition(gotoX + 18, gotoY + 20);
		printf_s("                   \n");
		SetCursorPosition(gotoX + 18, gotoY + 21);
		printf_s("      N E X T      \n");
		SetCursorPosition(gotoX + 18, gotoY + 22);
		printf_s("                   ");
		SetColor(WHITE, BLACK);
		SetCursorPosition(gotoX + 40, gotoY + 5);
		printf_s("¢¸ %d*%d ¢º", m_MapSize, m_MapSize);
		SetCursorPosition(gotoX + 40, gotoY + 8);
		printf_s("¢¸  %d  ¢º", m_NumShip[0]);
		SetCursorPosition(gotoX + 40, gotoY + 11);
		printf_s("¢¸  %d  ¢º", m_NumShip[1]);
		SetCursorPosition(gotoX + 40, gotoY + 14);
		printf_s("¢¸  %d  ¢º", m_NumShip[2]);
		SetCursorPosition(gotoX + 40, gotoY + 17);
		printf_s("¢¸  %d  ¢º", m_NumShip[3]);
		SetCursorPosition(gotoX, currentY);
		printf_s("¢º");
		menuSelector = MenuSelect(6, gotoX, gotoY, currentY, gameStatus);
		break;
//.........这里部分代码省略.........
开发者ID:WooJaeWoo,项目名称:Smith_CPP,代码行数:101,代码来源:GameInterface.cpp


注:本文中的printf_s函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。