Funcode-貪吃蛇

自己編寫的一個小游戲,本來打算做貪吃蛇,結果不會使蛇的身子隨蛇頭方向改變而改變就換了種想法,最后變成了這樣一個另類的小游戲,“笑哭“,下面是程序的主要代碼,如果有興趣也可以下載完整程序代碼資源:https://download.csdn.net/download/yt201758501112/10488198。

Lessonx.h

/

//
//
//
//
/
#ifndef _LESSON_X_H_
#define _LESSON_X_H_
//
#include <Windows.h>
#include <stdio.h>
#include <vector>
using namespace std;
/
//
// 游戲總管類。負責處理游戲主循環、游戲初始化、結束等工作
class CGameMain
{
private:
int m_iGameState; // 游戲狀態,0:結束或者等待開始;1:初始化;2:游戲進行中
? ? CSprite * m_pControlSnake; ? ? ? ? //定義蛇頭部精靈
? ? CSprite * m_pSnakebody1; ? ? ? ? ? ?//定義一節蛇身
? ? CSprite * tmpsprite; ? ? ? ? ? ? //定義兩個中間變量精靈
? ? CSprite * tmpsprite1;
? ? vector<CSprite*> ?m_pSnakefood; ? ? ?//定義食物精靈組
? ? vector<CSprite*> ?m_pzhangai; ? ? ? ?//定義障礙精靈組
? ? CTextSprite * m_pStarttext; ? ? ?//定義開始文本精靈
? ? CTextSprite * m_pgamescore; ? ? ?//定義分數文本精靈
? ? CTextSprite * m_plevel; ? ? ? ?//定義級別文本精靈
? ? CSprite * m_pgameover; ? ? ? ? ?//定義游戲結束時背景精靈
? ? CSprite * m_pbeijing; ? ? ? ? ?//定義開始時背景精靈
? ? CTextSprite * m_ptime; ? ? ? ? //定義游戲時間文本精靈
? ? CTextSprite * m_pend1; ? ? ? ? //定義文本精靈
? ? CTextSprite * m_pend2;
? ? CSound * m_bjmusic; ? ? ? ? ?//定義音效精靈
? ? CSound * m_eatmusic;
? ? int m_foodminX; ? ? ? ?//定義食物出現的最小X坐標
? ? int m_foodmaxX; ? ? ? ? //定義食物出現的最大X坐標
? ? int m_foodminY; ? ? ? ? //定義食物出現的最小Y坐標
? ? int m_foodmaxY; ? ? ? ? //定義食物出現的最大Y坐標
? ? int m_foodcount; ? ? ? ?//定義食物出現的數目
? ? int m_zhangaimaxY; ? ? ?//定義障礙出現的最大Y坐標
? ? int m_zhangaiminY; ? ? ?//定義障礙出現的最小Y坐標
? ? int m_zhangaicount; ? ? //定義障礙出現的數目
? ? float DeltaTime; ? ? ? ?//定義時間
? ? float speedsnake; ? ? ? //定義蛇移動的速度
? ? int weizhi; ? ? ? ?//定義需要的變量
? ? int judge;
? ? float speedbeijing;
? ? int t;
? ? char foodname[1000]; ? ? ?//定義需要存儲的數組
? ? char zhangainame[1000];
? ? int fenshu; ? ? ? ? //定義級別,分數
? ? int level;
? ? float mintime,maxtime;
? ? float basetime;
public:
CGameMain(); ? ? ? ? ? ?//構造函數
~CGameMain(); ? ? ? ? ? //析構函數


// Get方法
int GetGameState() { return m_iGameState; }


// Set方法
void SetGameState( const int iState ) { m_iGameState = iState; }


// 游戲主循環等
void GameMainLoop( float fDeltaTime );
void GameInit();
void GameRun( float fDeltaTime );
void GameEnd();
void OnMouseMove( const float fMouseX, const float fMouseY );
void OnMouseClick( const int iMouseType, const float fMouseX, const float fMouseY );
void OnMouseUp( const int iMouseType, const float fMouseX, const float fMouseY );
void OnKeyDown( const int iKey, const bool bAltPress, const bool bShiftPress, const bool bCtrlPress );
void OnKeyUp( const int iKey );
void OnSpriteColSprite( const char *szSrcName, const char *szTarName );
void OnSpriteColWorldLimit( const char *szName, const int iColSide );
};


/
//
extern CGameMain g_GameMain;

?

#endif // _LESSON_X_H_

?

?

?

?

Lessonx.cpp

/
//
//
//
//
/
#include <Stdio.h>
#include "CommonClass.h"
#include "LessonX.h"
#include <algorithm>
#include <cstring>
#include <time.h>
#include <stdlib.h>
#include<windows.h>
#pragma comment(lib,"winmm.lib")

//
//
CGameMain g_GameMain;


//==============================================================================
//
// 大體的程序流程為:GameMainLoop函數為主循環函數,在引擎每幀刷新屏幕圖像之后,都會被調用一次。


//==============================================================================
//
// 構造函數
CGameMain::CGameMain()
{
m_iGameState = 0;
m_pControlSnake =new CSprite("Snake_0"); ? ? ? ?//導入精靈
m_pSnakebody1 =new CSprite("snake_1");
m_pStarttext =new CTextSprite("start"); ? ? ? ?//導入文本精靈
m_pgamescore=new CTextSprite("gamescore");
m_plevel=new CTextSprite("level");
m_pgameover=new CSprite("gameend");
m_pbeijing=new CSprite("beijing");
m_ptime=new CTextSprite("time");
m_bjmusic=new CSound("bjmusic.wav",1,1); ? ? ? ?//導入音樂精靈
m_eatmusic=new CSound("eatmusic.wav",0,1);
m_pend1=new CTextSprite("end1");
m_pend2=new CTextSprite("end2");
m_foodmaxX=0; ? ? ? ? ?//初始化變量
m_foodmaxY=0;
m_foodminX=0;
m_foodminY=0;
m_foodcount=0;
DeltaTime=0;
? ? speedbeijing=10.f;
? ? speedsnake=15.f;
? ? basetime=0.f;
? ? m_iHook=0;
weizhi=0;
judge=1;
t=0;
fenshu=0;
level=1;
mintime=2.f;
maxtime=4.f;
iTime=0;
}
//==============================================================================
//
// 析構函數
CGameMain::~CGameMain()
{
}


//==============================================================================
//
// 游戲主循環,此函數將被不停的調用,引擎每刷新一次屏幕,此函數即被調用一次
// 用以處理游戲的開始、進行中、結束等各種狀態.
// 函數參數fDeltaTime : 上次調用本函數到此次調用本函數的時間間隔,單位:秒
void CGameMain::GameMainLoop( float fDeltaTime )
{
switch( GetGameState() )
{
// 初始化游戲,清空上一局相關數據
case 1:
{
GameInit();
SetGameState(2); // 初始化之后,將游戲狀態設置為進行中
}
break;


// 游戲進行中,處理各種游戲邏輯
case 2:
{
// TODO 修改此處游戲循環條件,完成正確游戲邏輯
if( true )
{
GameRun( fDeltaTime );


}
else // 游戲結束。調用游戲結算函數,并把游戲狀態修改為結束狀態
{
SetGameState(0);
GameEnd();
}
}
break;


// 游戲結束/等待按空格鍵開始
case 0:
default:
break;
};
}
//=============================================================================
//
// 每局開始前進行初始化,清空上一局相關數據
void CGameMain::GameInit()
{


}
//=============================================================================
//
// 每局游戲進行中
void CGameMain::GameRun( float fDeltaTime )
{
? ? ? ?DeltaTime+=fDeltaTime; ? ? ? //累加時間來判斷是否產生障礙
? ? ? ?basetime+=fDeltaTime; ? ? ? ? ? //累加時間以用來計時
? ? ?m_ptime->SetTextValueFloat(basetime);
? ? ?if(judge==1) ? ? ? ? ? ?//判斷當蛇頭吃到食物時產生新的食物
? ? ?{
? ? ? ? sprintf(foodname,"food%d",m_foodcount++); ? ? ? ? ?//改變食物的名字
? ? ? ? tmpsprite=new CSprite(foodname); ? ? ? ? ?//初始化中間精靈
? ? ? ? tmpsprite->CloneSprite("food0"); ? ? ? ?//克隆初始食物精靈
? ? ? ? m_foodmaxX=31; ? ? ? ? ? ? //根據原圖判斷邊界坐標
? ? ? ? m_foodminX=-49;
? ? ? ? m_foodmaxY=31;
? ? ? ? m_foodminY=-36;
? ? ? ? int iposX=CSystem::RandomRange(m_foodminX,m_foodmaxX); ? ? ? ? ? //隨機產生食物的X坐標
? ? ? ? int iposY=CSystem::RandomRange(m_foodminY,m_foodmaxY); ? ? ? ? ? //隨機產生食物的Y坐標
? ? ? ? tmpsprite->SetSpritePosition(iposX,iposY); ? ? ? ? ? ? ? //根據隨機產生的坐標將精靈置入游戲界面中
? ? ? ? m_pControlSnake->SetSpriteCollisionSend(true); ? ? ? ? ? //設置頭部精靈發送信號
? ? ? ? tmpsprite->SetSpriteCollisionReceive(true); ? ? ? ? ? ?//設置食物精靈接受信號
? ? ? ? judge=0; ? ? ? ? ? ? //把判斷值初始化
? ? ?}


? ? ?if(DeltaTime>mintime&&DeltaTime<maxtime) ? ? ? ? ? ? //當達到相應的時間時產生一障礙
? ? ?{
? ? ? ? ?sprintf(zhangainame,"box%d",m_zhangaicount++); ? ? ? ? ? //改變障礙的名字
? ? ? ? ?tmpsprite1=new CSprite(zhangainame); ? ? ? ? ? ?//初始化中間變量精靈
? ? ? ? ?tmpsprite1->CloneSprite("box0"); ? ? ? ? ? ? //克隆初始障礙
? ? ? ? ?m_zhangaiminY=-35; ? ? ? ? ? ? //根據原圖判斷坐標范圍
? ? ? ? ?m_zhangaimaxY=35;
? ? ? ? ?int posY=CSystem::RandomRange(m_zhangaiminY,m_zhangaimaxY); ? ? ? ? ? ? //隨機產生Y值
? ? ? ? ?int posX=50;
? ? ? ? ?tmpsprite1->SetSpritePosition(posX,posY); ? ? ? ? ? ? //置入障礙
? ? ? ? ?tmpsprite1->SetSpriteCollisionReceive(true); ? ? ? ? ? ? ? //設置障礙可以接受信號
? ? ? ? ?tmpsprite1->SetSpriteLinearVelocity(-speedbeijing,0); ? ? ? ? ? //設置障礙的移動速度
? ? ? ? ?DeltaTime=0; ? ? ? ? ?//初始化變量
? ? ?}
? ? ?if(fenshu>=50&&fenshu<=100) ? ? ? ? ? ? //根據分數的不同變化關卡
? ? ?{
? ? ? ? speedbeijing=15.f; ? ? ? ? ? ? ? //設置第二關障礙,蛇的移動速度
? ? ? ? speedsnake=20.f;
? ? ? ? level=2; ? ? ? ? ?//改變關卡級別
? ? ? ? m_plevel->SetTextValue(level);
? ? ? ? mintime=1.8; ? ? ? ? //改變障礙出現的時間間隔
? ? ? ? maxtime=3.6;
? ? ? ?// m_pbeijing->SetSpriteLinearVelocity(speedbeijing,0);
? ? ?}
? ? ?if(fenshu>100&&fenshu<=150)
? ? ?{
? ? ? ? ?speedbeijing=20.f; ? ? ? ? //設置第三關障礙,蛇的移動速度
? ? ? ? ?speedsnake=25.f;
? ? ? ? ?level=3; ? ? ? ? ? //改變關卡級別
? ? ? ? m_plevel->SetTextValue(level);
? ? ? ? mintime=1.6; ? ? ? ? ? ?//改變障礙出現的時間間隔
? ? ? ? maxtime=3.2;
? ? ? ?// m_pbeijing->SetSpriteLinearVelocity(speedbeijing,0);
? ? ?}
? ? ?if(fenshu>150&&fenshu<=200)
? ? ?{
? ? ? ? ?speedbeijing=25.f; ? ? ? ? ? ? //設置第四關障礙,蛇的移動速度
? ? ? ? ?speedsnake=30.f;
? ? ? ? ?level=4; ? ? ? ? ? //改變關卡級別
? ? ? ? m_plevel->SetTextValue(level);
? ? ? ? mintime=1.4; ? ? ? ? ? ?//改變障礙出現的時間間隔
? ? ? ? maxtime=2.8;
? ? ?// ? m_pbeijing->SetSpriteLinearVelocity(speedbeijing,0);
? ? ?}
? ? ?if(fenshu>200)
? ? ?{
? ? ? ? ?speedbeijing=30.f; ? ? ? ? ? ? //設置第五關障礙,蛇的移動速度
? ? ? ? ?speedsnake=35.f;
? ? ? ? ?level=5; ? ? ? ? ? //改變關卡級別
? ? ? ? ?m_plevel->SetTextValue(level);
? ? ? ? ?mintime=1.0; ? ? ? ? ? //改變障礙出現的時間間隔
? ? ? ? ?maxtime=2;
? ? ? //s ? m_pbeijing->SetSpriteLinearVelocity(speedbeijing,0);
? ? ?}
}
//=============================================================================
//
// 本局游戲結束
void CGameMain::GameEnd()
{
}
//==========================================================================
//
// 鼠標移動
// 參數 fMouseX, fMouseY:為鼠標當前坐標
void CGameMain::OnMouseMove( const float fMouseX, const float fMouseY )
{


}
//==========================================================================
//
// 鼠標點擊
// 參數 iMouseType:鼠標按鍵值,見 enum MouseTypes 定義
// 參數 fMouseX, fMouseY:為鼠標當前坐標
void CGameMain::OnMouseClick( const int iMouseType, const float fMouseX, const float fMouseY )
{


}
//==========================================================================
//
// 鼠標彈起
// 參數 iMouseType:鼠標按鍵值,見 enum MouseTypes 定義
// 參數 fMouseX, fMouseY:為鼠標當前坐標
void CGameMain::OnMouseUp( const int iMouseType, const float fMouseX, const float fMouseY )
{


}
//==========================================================================
//
// 鍵盤按下
// 參數 iKey:被按下的鍵,值見 enum KeyCodes 宏定義
// 參數 iAltPress, iShiftPress,iCtrlPress:鍵盤上的功能鍵Alt,Ctrl,Shift當前是否也處于按下狀態(0未按下,1按下)
void CGameMain::OnKeyDown( const int iKey, const bool bAltPress, const bool bShiftPress, const bool bCtrlPress )
{
? ? if( KEY_SPACE == iKey && 0 == GetGameState() )
{
SetGameState( 1 );
? ? ? ? m_pStarttext->SetSpriteVisible(false); ? ? ? ? ?//設置當按下空格時開始文本精靈消失
? ? }
? ? float fSpeedX=0.f,fSpeedY=0.f;
? ? float fdirector=0.f;
? ? switch(iKey) ? ? ? ? ? ? //設置按鍵對蛇頭精靈速度的影響
? ? {
? ? ? ? case KEY_W:
? ? ? ? ? ? fSpeedY=-speedsnake;
? ? ? ? ? ? fdirector=270.f;
? ? ? ? ? ? break;
? ? ? ? case KEY_A:
? ? ? ? ? ? fSpeedX=-speedsnake;
? ? ? ? ? ? fdirector=180.f;
? ? ? ? ? ? break;
? ? ? ? case KEY_S:
? ? ? ? ? ? fSpeedY=speedsnake;
? ? ? ? ? ? fdirector=90.f;
? ? ? ? ? ? break;
? ? ? ? case KEY_D:
? ? ? ? ? ? fSpeedX=speedsnake;
? ? ? ? ? ? fdirector=0.f;
? ? ? ? ? ? break;
? ? };
? ? m_pControlSnake->SetSpriteLinearVelocity(fSpeedX, fSpeedY); ? ? ? //改變蛇頭的速度
? ? m_pControlSnake->SetSpriteRotation(fdirector); ? ? ? ? ? ?//改變蛇頭的朝向
}
//==========================================================================
//
// 鍵盤彈起
// 參數 iKey:彈起的鍵,值見 enum KeyCodes 宏定義
void CGameMain::OnKeyUp( const int iKey )
{


}
//==========================================================================
//
// 精靈與精靈碰撞
// 參數 szSrcName:發起碰撞的精靈名字
// 參數 szTarName:被碰撞的精靈名字
void CGameMain::OnSpriteColSprite( const char *szSrcName, const char *szTarName)
{
? ? if(stricmp("snake_0",szSrcName)==0&&stricmp(foodname,szTarName)==0) ? ? ? ? ? //當蛇頭與食物碰撞時
? ? {
? ? ? ? weizhi=weizhi-2;
? ? ? ? tmpsprite->SpriteMountToSprite("snake_0",weizhi,0); ? ? ? ? ? //將食物接在蛇頭后面
? ? ? ? judge=1; ? ? ? ? ? ? //改變判斷變量
? ? ? ? fenshu+=10; ? ? ? ? ?//改變分數
? ? ? ? m_pgamescore->SetTextValue(fenshu);
? ? ? ? PlaySound("E:\\eatmusic.wav",0,SND_FILENAME|SND_ASYNC); ? ? ? ?//播放吃食物的音效


? ? }
? ? else
? ? ? ? judge=0;
? ? if(stricmp("snake_0",szSrcName)==0&&stricmp(foodname,szTarName)!=0) ? ? ? ? ? ? //當蛇頭與障礙碰撞時
? ? {
? ? ? ? m_pControlSnake->DeleteSprite(); ? ? ? ? ? ? ?//刪除蛇頭與蛇身
? ? ? ? m_pgameover->SetSpritePosition(0,0); ? ? ? ? ?//導入游戲結束界面
? ? ? ? m_pgameover->SetSpriteVisible(true);
? ? ? ? m_pend1->SetSpritePosition(-2.5,0); ? ? ? ? ? //導入游戲終結文本
? ? ? ? m_pend2->SetSpritePosition(-4.9,6);
? ? ? ? m_pend2->SetTextValue(fenshu);


? ? }
}
//===========================================================================
//
// 精靈與世界邊界碰撞
// 參數 szName:碰撞到邊界的精靈名字
// 參數 iColSide:碰撞到的邊界 0 左邊,1 右邊,2 上邊,3 下邊
void CGameMain::OnSpriteColWorldLimit( const char *szName, const int iColSide )
{
? ? if(stricmp(szName,"snake_0")==0&&iColSide==0) ? ? ? ? ? ? //設置當蛇頭碰到邊界時結束游戲
? ? {
? ? ? ? m_pControlSnake->DeleteSprite();
? ? ? ? m_pgameover->SetSpritePosition(0,0);
? ? ? ? m_pgameover->SetSpriteVisible(true);
? ? ? ? m_pend1->SetSpritePosition(-2.5,0);
? ? ? ? m_pend2->SetSpritePosition(-4.9,6);
? ? ? ? m_pend2->SetTextValue(fenshu);
? ? }
? ? if(stricmp(szName,"snake_0")==0&&iColSide==1)
? ? {
? ? ? ? m_pControlSnake->DeleteSprite();
? ? ? ? m_pgameover->SetSpritePosition(0,0);
? ? ? ? m_pgameover->SetSpriteVisible(true);
? ? ? ? m_pend1->SetSpritePosition(-2.5,0);
? ? ? ? m_pend2->SetSpritePosition(-4.9,6);
? ? ? ? m_pend2->SetTextValue(fenshu);
? ? }
? ? if(stricmp(szName,"snake_0")==0&&iColSide==2)
? ? {
? ? ? ? m_pControlSnake->DeleteSprite();
? ? ? ? m_pgameover->SetSpritePosition(0,0);
? ? ? ? m_pgameover->SetSpriteVisible(true);
? ? ? ? m_pend1->SetSpritePosition(-2.5,0);
? ? ? ? m_pend2->SetSpritePosition(-4.9,6);
? ? ? ? m_pend2->SetTextValue(fenshu);
? ? }
? ? if(stricmp(szName,"snake_0")==0&&iColSide==3)
? ? {
? ? ? ? m_pControlSnake->DeleteSprite();
? ? ? ? m_pgameover->SetSpritePosition(0,0);
? ? ? ? m_pgameover->SetSpriteVisible(true);
? ? ? ? m_pend1->SetSpritePosition(-2.5,0);
? ? ? ? m_pend2->SetSpritePosition(-4.9,6);
? ? ? ? m_pend2->SetTextValue(fenshu);
? ? }
}

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/536459.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/536459.shtml
英文地址,請注明出處:http://en.pswp.cn/news/536459.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mac 使用遠程連接

https://www.jianshu.com/p/9cc90361f37a轉載于:https://www.cnblogs.com/xiangsj/p/10876400.html

systemtap執行過程中報probe timer.profile registration error

probe timer.profile registration error 今天在執行火焰圖的過程中&#xff0c;代碼報錯&#xff0c;probe timer.profile registration error 經過查詢、分析可能是在該平臺該函數是不安全、不共享的。 將 probe timer.profile { 用該代碼替換即可 probe perf.sw.cpu_clock !…

(十三)java版spring cloud+spring boot+redis社交電子商務平臺-springboot集成spring cache...

電子商務社交平臺源碼請加企鵝求求&#xff1a;一零三八七七四六二六。本文介紹如何在springboot中使用默認的spring cache&#xff0c;聲明式緩存Spring 定義 CacheManager 和 Cache 接口用來統一不同的緩存技術。例如 JCache、 EhCache、 Hazelcast、 Guava、 Redis 等。在使…

搭建gitlab及部署gitlab-runner

2019獨角獸企業重金招聘Python工程師標準>>> 1、搭建gitlab,之前yum安裝gitlab,安裝后一直報502錯誤,網上百度試過還是無法使用; 所以這次部署在docker里面;如下命令&#xff1a; docker run --detach --hostname gitlab.forebix.com --publish 4433:443 --publish …

母牛的故事

母牛的故事 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Description 有一對夫婦買了一頭母牛&#xff0c;它從第2年起每年年初生一頭小母牛。每頭小母牛從第四個年頭開始&#xff0c;每年年初也生一頭小母牛。請編程實現在第n年的時候…

軟件性能測試

通常&#xff0c;衡量一個軟件系統性能的常見指標有&#xff1a; 1、響應時間&#xff08;服務器端響應時間、網絡響應時間、客戶端響應時間&#xff09; 那客戶感受的響應時間其實是等于客戶端服務器端網絡響應時間 2、吞吐量 軟件系統在每單位時間內能處理多少個事務/請求/單…

王小二切餅

王小二切餅 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Description 王小二自夸刀工不錯&#xff0c;有人放一張大的煎餅在砧板上&#xff0c;問他&#xff1a;“餅不許離開砧板&#xff0c;切n(1<n<100)刀最多能分成多少塊&…

SmoothNLP 中文NLP文本處理工具 Python 實戰示范

SmoothNLP pythonJavaPython python interfaces for SmoothNLP 的 Python 接口&#xff0c; 支持自動下載底層jar包 &#xff0c;目前支持Python3 Pypi 官方安裝 pip3 install smoothnlp 復制代碼請注意使用python3安裝smoothnlp項目&#xff0c;當前版本 version0.2.4 如果您使…

本地緩存Caffeine

Caffeine 說起Guava Cache&#xff0c;很多人都不會陌生&#xff0c;它是Google Guava工具包中的一個非常方便易用的本地化緩存實現&#xff0c;基于LRU算法實現&#xff0c;支持多種緩存過期策略。由于Guava的大量使用&#xff0c;Guava Cache也得到了大量的應用。但是&#x…

《圖解HTTP》核心知識總結

HTTP協議的簡介 HTTP是超文本傳輸協議&#xff0c;用于客戶端和服務器端之間的通信&#xff0c;屬于TCP/IP中的應用層。 HTTP協議的基礎知識 客戶端和服務器端 客戶端是服務請求方&#xff0c;服務器端是服務提供方。 URI和URL URI:URI是統一資源標識符&#xff1b; URL:是統一…

1042: 篩法求素數

1042: 篩法求素數 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 1387 Solved: 918 [Submit][Status][Web Board] Description 用篩法求之N內的素數。 Input N Output 0&#xff5e;N的素數 Sample Input 100 Sample Output 2 3 5 7 11 13 17 19 23 29 31 37 4…

狀態機解析請求行

微信公眾號&#xff1a;鄭爾多斯關注「鄭爾多斯」公眾號 &#xff0c;回復「領取資源」&#xff0c;獲取IT資源500G干貨。升職加薪、當上總經理、出任CEO、迎娶白富美、走上人生巔峰&#xff01;想想還有點小激動關注可了解更多的Nginx知識。任何問題或建議&#xff0c;請公眾號…

GO 從零開始的語法學習二

for循環 if條件里不需要括號 err ! nil 判斷是否為空 func main(){const filename "abc.txt"contents , err : ioutil.ReadFile(filename); err ! nil{fmt.Println(err)} else{fmt.Printf("%s\n",contents)} } 復制代碼if的條件里可以進行賦值if的條件里…

7個有用的Vue開發技巧

1 狀態共享 隨著組件的細化&#xff0c;就會遇到多組件狀態共享的情況&#xff0c;Vuex當然可以解決這類問題&#xff0c;不過就像Vuex官方文檔所說的&#xff0c;如果應用不夠大&#xff0c;為避免代碼繁瑣冗余&#xff0c;最好不要使用它&#xff0c;今天我們介紹的是vue.js …

Kewail-郵件短信接口的基礎教程

短信接口接入流程開始接入手機短信接口接入操作流程&#xff1a;申請短信簽名 → 申請短信模板 → 生成AccessKey → 下載DEMO/攢寫接口調用文檔 → 免費測試發送 → 購買發信量正式使用。一、申請短信簽名接入API接口&#xff0c;通過1069通道發送驗證碼等短信&#xff0c;必須…

傳百度無人車計劃分拆,百度回復:不實信息,目前未有分拆計劃

據《財經》報道&#xff0c;百度無人車項目正在籌備分拆(spin off)當中&#xff0c;且正在尋找外部投資機構融資。一位接近百度無人車項目人士對《財經》表明&#xff0c;分拆就是時間問題。對于無人車項目分拆一事&#xff0c;百度對 36 氪表示&#xff0c;媒體報道不實。目前…

又見回文

又見回文 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Description “回文串”是一個正讀和反讀都一樣的字符串&#xff0c;比如“level”或者“noon”等等就是回文串。現在呢&#xff0c;就是讓你判斷輸入的字符串是否是回文串。 Inpu…

Fighting_小銀考呀考不過四級【遞推】

Fighting_小銀考呀考不過四級 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Description 四級考試已經過去好幾個星期了&#xff0c;但是小銀還是對自己的英語水平擔心不已。 小銀打算好好學習英語&#xff0c;爭取下次四級考試和小學弟小…

從xml中返回的對象,和new 返回的對象時不同的。

public BigDecimal getTax() {return tax null ? BigDecimal.ZERO : tax;} 這是自定義的一個類 對null 做出了處理。 但是如果是直接從xml 查詢返回的該對象&#xff0c; tax() 字段還是會產生null <resultMap id"twoToNine" type"" ><result …

三國佚事——巴蜀之危【遞推】

三國佚事——巴蜀之危 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Description 話說天下大勢&#xff0c;分久必合&#xff0c;合久必分。。。卻道那魏蜀吳三國鼎力之時&#xff0c;多少英雄豪杰以熱血譜寫那千古之絕唱。古人誠不我欺…