最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MATLAB實現五子棋游戲(雙人對戰(zhàn)、可悔棋)

 更新時間:2019年06月18日 11:21:51   作者:ArcheL  
這篇文章主要為大家詳細介紹了MATLAB實現五子棋游戲,可以進行雙人對戰(zhàn)、也可悔棋,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了MATLAB實現五子棋游戲的具體代碼,供大家參考,具體內容如下

程序介紹:

1、此游戲只可用于雙人對戰(zhàn)。

2、棋盤顏色、棋盤格數、棋子顏色等參數均可自由設置

3、鼠標點擊非棋盤區(qū)域可悔棋。

一、游戲界面

二、主程序及函數

1、主程序

%Author:LeiZhen
%Date:2018-03-12
%此程序只下五子棋,并判斷勝負關系
clear all;
clc
%定義顏色
Color_QiPanBack=[135,206,255];
Color_ChessLine=[100,100,100];
%獲勝連子數
Num_Victory=5;
Dpixel=33;
NumCell=14;%棋盤格的行或列數
Wid_edge=18;
[M_QiPan,xcol_ChessLine,yrow_ChessLine]=QiPan(NumCell,Dpixel,Wid_edge,Color_QiPanBack,Color_ChessLine);
imshow(M_QiPan);
set (gcf,'Position',[600,45,625,625]);
set (gca,'Position',[0,0,1,1]);
hold on,
%棋半徑
radius_Chess=15;
M_LuoZi=zeros(NumCell+1,NumCell+1,2);
VictoryB=0;
VictoryW=0;
StateB=1;
StateW=2;
NumChess=0;
for i=1:(NumCell+1)^2
  [x_col_Chess, y_row_Chess]=ginput_pointer(1);
  %獲得距離鼠標點擊點最近的下棋點的坐標,并保證點擊的下棋點在棋盤內
  if x_col_Chess<max(xcol_ChessLine)+Dpixel/2&&x_col_Chess>min(xcol_ChessLine)-Dpixel/2&&y_row_Chess<max(yrow_ChessLine)+Dpixel/2&&y_row_Chess>min(yrow_ChessLine)-Dpixel/2
    for x_i=xcol_ChessLine
      if abs(x_col_Chess-x_i)<Dpixel/2;
        x_col_Chess=x_i;
      end
    end
    for y_i=yrow_ChessLine
      if abs(y_row_Chess-y_i)<Dpixel/2;
        y_row_Chess=y_i;
      end
    end
  %點擊悔棋區(qū)(棋盤外的區(qū)域)悔棋
  else
    [x_col_LuoZi_old,y_row_LuoZi_old]=find(M_LuoZi(:,:,2)==max(max(M_LuoZi(:,:,2))));
    x_col_Chess_old=(x_col_LuoZi_old-1)*Dpixel+Wid_edge+1;
    y_row_Chess_old=(y_row_LuoZi_old-1)*Dpixel+Wid_edge+1;
    if NumChess>=1
      M_QiPan=Chess(M_QiPan,x_col_Chess_old,y_row_Chess_old,radius_Chess,3,Wid_edge,Dpixel,Color_QiPanBack,Color_ChessLine);
      imshow(M_QiPan);
      NumChess=NumChess-1;
      M_LuoZi(x_col_LuoZi_old,y_row_LuoZi_old,1)=0;
      M_LuoZi(x_col_LuoZi_old,y_row_LuoZi_old,2)=0;
    end
    continue;
  end
  %落子并防止重復在同一個下棋點落子
  x_col_LuoZi=(x_col_Chess-Wid_edge-1)/Dpixel+1;
  y_row_LuoZi=(y_row_Chess-Wid_edge-1)/Dpixel+1;
  if M_LuoZi(x_col_LuoZi,y_row_LuoZi,1)==0
    NumChess=NumChess+1;
    M_LuoZi(x_col_LuoZi,y_row_LuoZi,2)=NumChess;
    if mod(NumChess,2)==1
      M_QiPan=Chess(M_QiPan,x_col_Chess,y_row_Chess,radius_Chess,1,Wid_edge,Dpixel,Color_QiPanBack,Color_ChessLine);
      imshow(M_QiPan);
      M_LuoZi(x_col_LuoZi,y_row_LuoZi,1)=StateB; %落子為黑棋
      VictoryB=Victory_Judge(M_LuoZi,x_col_LuoZi,y_row_LuoZi,StateB);
    elseif mod(NumChess,2)==0
      M_QiPan=Chess(M_QiPan,x_col_Chess,y_row_Chess,radius_Chess,2,Wid_edge,Dpixel,Color_QiPanBack,Color_ChessLine);
      imshow(M_QiPan);
      M_LuoZi(x_col_LuoZi,y_row_LuoZi,1)=StateW; %落子為白棋
      VictoryW=Victory_Judge(M_LuoZi,x_col_LuoZi,y_row_LuoZi,StateW);
    end
  end
  %顯示獲勝信息
  if VictoryB==1
    %普通對話框
    h=dialog('name','對局結束','position',[500 350 250 100]);
    uicontrol('parent',h,'style','text','string','黑棋獲勝!','position',[35 35 200 50],'fontsize',30);
    uicontrol('parent',h,'style','pushbutton','position',[150 5 80 30],'fontsize',20,'string','確定','callback','delete(gcbf)');
    break;
  elseif VictoryW==1
    %普通對話框
    h=dialog('name','對局結束','position',[500 350 250 100]);
    uicontrol('parent',h,'style','text','string','白棋獲勝!','position',[35 35 200 50],'fontsize',30);
    uicontrol('parent',h,'style','pushbutton','position',[150 5 80 30],'fontsize',20,'string','確定','callback','delete(gcbf)');
    break;
  end
end

2、畫棋盤函數

%Author:LeiZhen
%Date:2018-03-12
function [M_QiPan, xcol_ChessLine,yrow_ChessLine]=QiPan(NumCell, Dpixel, Wid_edge,Color_QiPanBack,Color_ChessLine)
%此程序為畫五子棋盤的程序
%NumCell為棋盤格數
%Dpixel為相鄰棋盤線間的像素間隔
%Wid_edge為棋盤邊緣的像素寬度
%Color_QiPanBack為棋盤背景顏色
%Color_ChessLine為棋盤線的顏色
%M_QiPan為棋盤矩陣
%xcol_ChessLine為棋盤列線
%yrow_ChessLine為棋盤行線
NumSum=1+Dpixel*NumCell+Wid_edge*2;
xcol_ChessLine=Wid_edge+1:Dpixel:NumSum-Wid_edge;%列
yrow_ChessLine=Wid_edge+1:Dpixel:NumSum-Wid_edge;%行
M_QiPan=uint8(ones(NumSum,NumSum,3));
M_QiPan(:,:,1)=M_QiPan(:,:,1)*Color_QiPanBack(1);
M_QiPan(:,:,2)=M_QiPan(:,:,2)*Color_QiPanBack(2);
M_QiPan(:,:,3)=M_QiPan(:,:,3)*Color_QiPanBack(3);
%畫棋盤線
for i=xcol_ChessLine
  M_QiPan(i,Wid_edge+1:NumSum-Wid_edge,:)=ones(NumSum-2*Wid_edge,1)*Color_ChessLine;
end
for j=yrow_ChessLine
  M_QiPan(Wid_edge+1:NumSum-Wid_edge,j,:)=ones(NumSum-2*Wid_edge,1)*Color_ChessLine;
end
%畫9個小圓點
radius_Dot=5;
P1=Wid_edge+1+Dpixel*3:Dpixel*(NumCell/2-3):Wid_edge+1+Dpixel*(NumCell-3);
for ti=P1
  for tj=P1
    for Num=ti-radius_Dot:ti+radius_Dot;
      for j=tj-radius_Dot:tj+radius_Dot;
        if (Num-ti)^2+(j-tj)^2<radius_Dot^2
          M_QiPan(Num,j,:)=Color_ChessLine;
        end
      end
    end
  end
end
end

3、下棋或悔棋函數

%Author:LeiZhen
%Date:2018-03-12
function M_QiPan=Chess(M_QiPan,x_col_Chess,y_row_Chess,radius_Chess,BorW,Wid_edge,Dpixel,Color_QiPanBack,Color_ChessLine)
%此程序下棋或者悔棋
%M_QiPan為棋盤矩陣
%xcol_ChessLine為棋盤列線
%yrow_ChessLine為棋盤行線
%radius_Chess為棋的像素半徑
%BorW為下棋選擇,1黑棋,2白棋,3悔棋
%Wid_edge為棋盤矩陣中的棋盤邊緣的像素寬度
%Dpixel為棋盤矩陣中的相鄰棋盤線間的像素間隔
%Color_QiPanBack為棋盤背景顏色
%Color_ChessLine為棋盤線的顏色
Color_BChess=[54,54,54];
Color_WChess=[255,240,245];
[Wid,Hei,Deep]=size(M_QiPan);
for i=x_col_Chess-radius_Chess:x_col_Chess+radius_Chess
  for j=y_row_Chess-radius_Chess:y_row_Chess+radius_Chess
    if (i-x_col_Chess)^2+(j-y_row_Chess)^2<=radius_Chess^2
      if BorW==1%黑棋
        M_QiPan(j,i,:)=Color_BChess;
      elseif BorW==2%白棋
        M_QiPan(j,i,:)=Color_WChess;
      elseif BorW==3%悔棋
        M_QiPan(j,i,:)=Color_QiPanBack;
        %對于不是棋盤邊緣的棋子
        if i==x_col_Chess||j==y_row_Chess
          M_QiPan(j,i,:)=Color_ChessLine;
        end
        %悔棋點是否為小圓點
        if ((i-x_col_Chess)^2+(j-y_row_Chess)^2<5^2)&&...
          (x_col_Chess==Wid_edge+1+Dpixel*3||x_col_Chess==floor(Wid/2)+1||x_col_Chess==Wid-Wid_edge-Dpixel*3)&&...
          (y_row_Chess==Wid_edge+1+Dpixel*3||y_row_Chess==floor(Wid/2)+1||y_row_Chess==Wid-Wid_edge-Dpixel*3)      
          M_QiPan(j,i,:)=Color_ChessLine;
        end
        %對于棋盤邊緣的棋子
        if x_col_Chess==Wid_edge+1&&i<x_col_Chess
          M_QiPan(j,i,:)=Color_QiPanBack;
        elseif x_col_Chess==Wid-Wid_edge&&i>x_col_Chess
          M_QiPan(j,i,:)=Color_QiPanBack;
        end
        if y_row_Chess==Wid_edge+1&&j<y_row_Chess
          M_QiPan(j,i,:)=Color_QiPanBack;
        elseif y_row_Chess==Wid-Wid_edge&&j>y_row_Chess
          M_QiPan(j,i,:)=Color_QiPanBack;
        end
      end
    end
  end
end
end

4、勝負判斷函數

%Author:LeiZhen
%Date:2018-03-12
function Victory_flag=Victory_Judge(M_LuoZi,x_col_LuoZi,y_row_LuoZi,State)
%對一方是否獲勝的判斷函數
%M_LuoZi為下棋點的矩陣
%x_col_LuoZi為下棋列數
%y_row_LuoZi下棋行數
%State為M_LuoZi矩陣某點的下棋狀態(tài),黑棋(1)或白棋(2)或無棋(0),以及每步棋的序號
%NumCell為棋盤格數
%Victory_flag為勝利標志
NumCell=length(M_LuoZi)-1;
Victory_flag=0;
for i=1:NumCell-3
  if M_LuoZi(i,y_row_LuoZi,1)==State&&M_LuoZi(i+1,y_row_LuoZi,1)==State&&M_LuoZi(i+2,y_row_LuoZi,1)==State&&M_LuoZi(i+3,y_row_LuoZi,1)==State&&M_LuoZi(i+4,y_row_LuoZi,1)==State
    Victory_flag=1;
    break;
  end
  if M_LuoZi(x_col_LuoZi,i,1)==State&&M_LuoZi(x_col_LuoZi,i+1,1)==State&&M_LuoZi(x_col_LuoZi,i+2,1)==State&&M_LuoZi(x_col_LuoZi,i+3,1)==State&&M_LuoZi(x_col_LuoZi,i+4,1)==State
    Victory_flag=1;
    break;
  end
  if abs(x_col_LuoZi-y_row_LuoZi)+i<=NumCell-3
    if x_col_LuoZi>=y_row_LuoZi
      if M_LuoZi(abs(x_col_LuoZi-y_row_LuoZi)+i,i,1)==State&&M_LuoZi(abs(x_col_LuoZi-y_row_LuoZi)+i+1,i+1,1)==State&&M_LuoZi(abs(x_col_LuoZi-y_row_LuoZi)+i+2,i+2,1)==State&&M_LuoZi(abs(x_col_LuoZi-y_row_LuoZi)+i+3,i+3,1)==State&&M_LuoZi(abs(x_col_LuoZi-y_row_LuoZi)+i+4,i+4,1)==State
        Victory_flag=1;
        break;
      end
    elseif x_col_LuoZi<y_row_LuoZi
      if M_LuoZi(i,abs(x_col_LuoZi-y_row_LuoZi)+i,1)==State&&M_LuoZi(i+1,abs(x_col_LuoZi-y_row_LuoZi)+i+1,1)==State&&M_LuoZi(i+2,abs(x_col_LuoZi-y_row_LuoZi)+i+2,1)==State&&M_LuoZi(i+3,abs(x_col_LuoZi-y_row_LuoZi)+i+3,1)==State&&M_LuoZi(i+4,abs(x_col_LuoZi-y_row_LuoZi)+i+4,1)==State
        Victory_flag=1;
        break;
      end
    end
  end
  if y_row_LuoZi+x_col_LuoZi<=NumCell+2&&y_row_LuoZi+x_col_LuoZi-i>=5
    if M_LuoZi(y_row_LuoZi+x_col_LuoZi-i,i,1)==State&&M_LuoZi(y_row_LuoZi+x_col_LuoZi-i-1,i+1,1)==State&&M_LuoZi(y_row_LuoZi+x_col_LuoZi-i-2,i+2,1)==State&&M_LuoZi(y_row_LuoZi+x_col_LuoZi-i-3,i+3,1)==State&&M_LuoZi(y_row_LuoZi+x_col_LuoZi-i-4,i+4,1)==State
      Victory_flag=1;
      break;
    end
  elseif y_row_LuoZi+x_col_LuoZi>NumCell+2&&y_row_LuoZi+x_col_LuoZi+i<=NumCell*2-1
    offset=NumCell+2;
    if M_LuoZi(y_row_LuoZi+x_col_LuoZi-offset+i,offset-i,1)==State&&M_LuoZi(y_row_LuoZi+x_col_LuoZi-offset+i+1,offset-i-1,1)==State&&M_LuoZi(y_row_LuoZi+x_col_LuoZi-offset+i+2,offset-i-2,1)==State&&M_LuoZi(y_row_LuoZi+x_col_LuoZi-offset+i+3,offset-i-3,1)==State&&M_LuoZi(y_row_LuoZi+x_col_LuoZi-offset+i+4,offset-i-4,1)==State
      Victory_flag=1;
      break;
    end
  end
end
end

5、光標函數(由庫函數改動而來)

%此函數為庫函數的修改,僅將十字光標改為箭頭光標,改動位置為第88行
function [out1,out2,out3] = ginput_pointer(arg1)
%GINPUT Graphical input from mouse.
%  [X,Y] = GINPUT(N) gets N points from the current axes and returns
%  the X- and Y-coordinates in length N vectors X and Y. The cursor
%  can be positioned using a mouse. Data points are entered by pressing
%  a mouse button or any key on the keyboard except carriage return,
%  which terminates the input before N points are entered.
%
%  [X,Y] = GINPUT gathers an unlimited number of points until the
%  return key is pressed.
%
%  [X,Y,BUTTON] = GINPUT(N) returns a third result, BUTTON, that
%  contains a vector of integers specifying which mouse button was
%  used (1,2,3 from left) or ASCII numbers if a key on the keyboard
%  was used.
%
%  Examples:
%    [x,y] = ginput;
%
%    [x,y] = ginput(5);
%
%    [x, y, button] = ginput(1);
%
%  See also GTEXT, WAITFORBUTTONPRESS.
 
%  Copyright 1984-2011 The MathWorks, Inc.
%  $Revision: 5.32.4.18 $ $Date: 2011/05/17 02:35:09 $
 
out1 = []; out2 = []; out3 = []; y = [];
c = computer;
if ~strcmp(c(1:2),'PC')
  tp = get(0,'TerminalProtocol');
else
  tp = 'micro';
end
 
if ~strcmp(tp,'none') && ~strcmp(tp,'x') && ~strcmp(tp,'micro'),
  if nargout == 1,
    if nargin == 1,
      out1 = trmginput(arg1);
    else
      out1 = trmginput;
    end
  elseif nargout == 2 || nargout == 0,
    if nargin == 1,
      [out1,out2] = trmginput(arg1);
    else
      [out1,out2] = trmginput;
    end
    if nargout == 0
      out1 = [ out1 out2 ];
    end
  elseif nargout == 3,
    if nargin == 1,
      [out1,out2,out3] = trmginput(arg1);
    else
      [out1,out2,out3] = trmginput;
    end
  end
else
  
  fig = gcf;
  figure(gcf);
  
  if nargin == 0
    how_many = -1;
    b = [];
  else
    how_many = arg1;
    b = [];
    if ischar(how_many) ...
        || size(how_many,1) ~= 1 || size(how_many,2) ~= 1 ...
        || ~(fix(how_many) == how_many) ...
        || how_many < 0
      error(message('MATLAB:ginput:NeedPositiveInt'))
    end
    if how_many == 0
      % If input argument is equal to zero points,
      % give a warning and return empty for the outputs.
      
      warning (message('MATLAB:ginput:InputArgumentZero'));
    end
  end
  
  % Setup the figure to disable interactive modes and activate pointers. 
  initialState = setupFcn(fig);
  set(gcf, 'pointer', 'arrow');
  
  % onCleanup object to restore everything to original state in event of
  % completion, closing of figure errors or ctrl+c. 
  c = onCleanup(@() restoreFcn(initialState));
    
  
  % We need to pump the event queue on unix
  % before calling WAITFORBUTTONPRESS
  drawnow
  char = 0;
  
  while how_many ~= 0
    % Use no-side effect WAITFORBUTTONPRESS
    waserr = 0;
    try
      keydown = wfbp;
    catch %#ok<CTCH>
      waserr = 1;
    end
    if(waserr == 1)
      if(ishghandle(fig))
        cleanup(c);
        error(message('MATLAB:ginput:Interrupted'));
      else
        cleanup(c);
        error(message('MATLAB:ginput:FigureDeletionPause'));
      end
    end
    % g467403 - ginput failed to discern clicks/keypresses on the figure it was
    % registered to operate on and any other open figures whose handle
    % visibility were set to off
    figchildren = allchild(0);
    if ~isempty(figchildren)
      ptr_fig = figchildren(1);
    else
      error(message('MATLAB:ginput:FigureUnavailable'));
    end
    %     old code -> ptr_fig = get(0,'CurrentFigure'); Fails when the
    %     clicked figure has handlevisibility set to callback
    if(ptr_fig == fig)
      if keydown
        char = get(fig, 'CurrentCharacter');
        button = abs(get(fig, 'CurrentCharacter'));
      else
        button = get(fig, 'SelectionType');
        if strcmp(button,'open')
          button = 1;
        elseif strcmp(button,'normal')
          button = 1;
        elseif strcmp(button,'extend')
          button = 2;
        elseif strcmp(button,'alt')
          button = 3;
        else
          error(message('MATLAB:ginput:InvalidSelection'))
        end
      end
      axes_handle = gca;
      drawnow;
      pt = get(axes_handle, 'CurrentPoint');
      
      how_many = how_many - 1;
      
      if(char == 13) % & how_many ~= 0)
        % if the return key was pressed, char will == 13,
        % and that's our signal to break out of here whether
        % or not we have collected all the requested data
        % points.
        % If this was an early breakout, don't include
        % the <Return> key info in the return arrays.
        % We will no longer count it if it's the last input.
        break;
      end
      
      out1 = [out1;pt(1,1)]; %#ok<AGROW>
      y = [y;pt(1,2)]; %#ok<AGROW>
      b = [b;button]; %#ok<AGROW>
    end
  end
  
  % Cleanup and Restore 
  cleanup(c);
  
  if nargout > 1
    out2 = y;
    if nargout > 2
      out3 = b;
    end
  else
    out1 = [out1 y];
  end
  
end
end
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function key = wfbp
%WFBP  Replacement for WAITFORBUTTONPRESS that has no side effects.
 
fig = gcf;
current_char = []; %#ok<NASGU>
 
% Now wait for that buttonpress, and check for error conditions
waserr = 0;
try
  h=findall(fig,'Type','uimenu','Accelerator','C');  % Disabling ^C for edit menu so the only ^C is for
  set(h,'Accelerator','');              % interrupting the function.
  keydown = waitforbuttonpress;
  current_char = double(get(fig,'CurrentCharacter')); % Capturing the character.
  if~isempty(current_char) && (keydown == 1)     % If the character was generated by the
    if(current_char == 3)              % current keypress AND is ^C, set 'waserr'to 1
      waserr = 1;                 % so that it errors out.
    end
  end
  
  set(h,'Accelerator','C');              % Set back the accelerator for edit menu.
catch %#ok<CTCH>
  waserr = 1;
end
drawnow;
if(waserr == 1)
  set(h,'Accelerator','C');             % Set back the accelerator if it errored out.
  error(message('MATLAB:ginput:Interrupted'));
end
if nargout>0, key = keydown; end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
function initialState = setupFcn(fig)
% Store Figure Handle. 
initialState.figureHandle = fig; 
% Suspend figure functions
initialState.uisuspendState = uisuspend(fig);
% Disable Plottools Buttons
initialState.toolbar = findobj(allchild(fig),'flat','Type','uitoolbar');
if ~isempty(initialState.toolbar)
  initialState.ptButtons = [uigettool(initialState.toolbar,'Plottools.PlottoolsOff'), ...
    uigettool(initialState.toolbar,'Plottools.PlottoolsOn')];
  initialState.ptState = get (initialState.ptButtons,'Enable');
  set (initialState.ptButtons,'Enable','off');
end
% Setup FullCrosshair Pointer without warning. 
oldwarnstate = warning('off', 'MATLAB:hg:Figure:Pointer');
set(fig,'Pointer','fullcrosshair');
warning(oldwarnstate);
% Adding this to enable automatic updating of currentpoint on the figure 
set(fig,'WindowButtonMotionFcn',@(o,e) dummy());
% Get the initial Figure Units
initialState.fig_units = get(fig,'Units');
end
function restoreFcn(initialState)
if ishghandle(initialState.figureHandle)
  % Figure Units
  set(initialState.figureHandle,'Units',initialState.fig_units);
  set(initialState.figureHandle,'WindowButtonMotionFcn','');
  
  % Plottools Icons
  if ~isempty(initialState.toolbar) && ~isempty(initialState.ptButtons)
    set (initialState.ptButtons(1),'Enable',initialState.ptState{1});
    set (initialState.ptButtons(2),'Enable',initialState.ptState{2});
  end
  
  % UISUSPEND
  uirestore(initialState.uisuspendState);
end
end
function dummy()
% do nothing, this is there to update the GINPUT WindowButtonMotionFcn. 
end
function cleanup(c)
if isvalid(c)
  delete(c);
end
end

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • 帶你粗略了解c++的最大乘積

    帶你粗略了解c++的最大乘積

    這篇文章主要為大家詳細介紹了C++的最大乘積,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能給你帶來幫助
    2021-08-08
  • C++中的extern聲明變量詳解

    C++中的extern聲明變量詳解

    這篇文章主要介紹了C++中的extern聲明變量詳解,本文講解了聲明和定義、extern聲明全局變量、extern聲明函數等內容,需要的朋友可以參考下
    2015-03-03
  • C++小知識:復制粘貼代碼千萬要小心

    C++小知識:復制粘貼代碼千萬要小心

    今天小編就為大家分享一篇關于C++小知識:復制粘貼代碼千萬要小心,小編覺得內容挺不錯的,現在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • C++使用適配器模式模擬實現棧和隊列

    C++使用適配器模式模擬實現棧和隊列

    不論是C語言還是C++,我們都用其對應的傳統(tǒng)寫法對棧和隊列進行了模擬實現,現在我們要用新的方法模擬實現棧和隊列,這個新方法就是適配器模式,文章通過代碼示例和圖文介紹的非常詳細,需要的朋友可以參考下
    2024-12-12
  • C++基于遞歸和非遞歸算法求二叉樹鏡像的方法

    C++基于遞歸和非遞歸算法求二叉樹鏡像的方法

    這篇文章主要介紹了C++基于遞歸和非遞歸算法求二叉樹鏡像的方法,針對二叉樹遍歷結合實例形式分析了遞歸與非遞歸算法的實現與使用技巧,需要的朋友可以參考下
    2017-05-05
  • C語言中enum關鍵字的實現示例

    C語言中enum關鍵字的實現示例

    這篇文章主要介紹了C語言中enum關鍵字的實現示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-03-03
  • C/C++中指針和引用之相關問題深入研究

    C/C++中指針和引用之相關問題深入研究

    從內存分配上看,程序為指針變量分配內存區(qū)域,而不為引用分配內存區(qū)域,因為引用聲明時必須初始化,從而指向一個已經存在的對象。引用不能指向空值
    2013-10-10
  • C語言 位域詳解及示例代碼

    C語言 位域詳解及示例代碼

    本文主要介紹C語言 位域的知識,這里整理了相關資料,并附示例代碼及詳解,有興趣的小伙伴可以參考下
    2016-08-08
  • C語言指針的長度和類型深入分析

    C語言指針的長度和類型深入分析

    這篇文章主要介紹了C語言指針的長度和類型,針對常見的各個類型進行了相對詳細的分析,需要的朋友可以參考下
    2014-09-09
  • C語言指針入門學習面面觀

    C語言指針入門學習面面觀

    這篇文章主要介紹了C語言指針的一些基礎知識,指針可以說是C語言入門學習中的頭等大事,文中從數組和函數等多方面剖析C中指針的作用,需要的朋友可以參考下
    2016-02-02

最新評論

和平区| 融水| 内乡县| 清河县| 元谋县| 乳源| 北辰区| 孝义市| 科技| 莆田市| 恩平市| 南平市| 云霄县| 曲麻莱县| 宽甸| 城市| 定州市| 高陵县| 沁水县| 镇雄县| 墨竹工卡县| 都兰县| 广东省| 松溪县| 保亭| 西平县| 宁乡县| 陈巴尔虎旗| 抚顺县| 台中市| 凭祥市| 怀安县| 镇平县| 宁蒗| 嵊泗县| 赫章县| 铜鼓县| 辽宁省| 新平| 梨树县| 三台县|