精华内容
下载资源
问答
  • 2012年芬兰数学家设计出数独游戏 中国程序员用计算机程序不到一秒就破解了 ...小弟不才,也试着写了一个,用是...游戏有四个难度:简单、中等、困难、超难(数独游戏) 还有很多不足之处,大家有兴趣可以自己改改
  • 一个简单的数独Demo

    2020-02-08 23:37:18
    闲来无事,想学习点东西,而最近又...下面是最简单的数独原型。还在不断完善中。 <!DOCTYPE html> <html> <head> <title>数独</title> <meta charset="utf-8...

    闲来无事,想学习点东西,而最近又在玩数独,于是乎准备使用各种技术折腾一个数独的小游戏。

    下面是最简单的,数独原型。还在不断完善中。

     

     

     

     

     

     

    <!DOCTYPE html>
    <html>
      <head>
        <title>数独</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <style type="text/css">
          html,body{height: 100%;user-select: none;}
          .container{height: 100%;}
          .flex-center{
            margin-top: 100px;
            height:auto;
            display:flex;
            justify-content: center;
            align-items: center;
          }
          .sudu-container{
            width: 450px;
            height: 450px;
            border: 1px solid #ddd;
            box-sizing: content-box;
            border-bottom: none;
          }
          .sudu-container :nth-child(9n){border-right: 0px;}
          .sudu-item{
            width: 50px;
            height: 50px;
            box-sizing: border-box;
            border-right: 1px solid #ddd;
            border-bottom: 1px solid #ddd;
            float: left;
            cursor: pointer;
            line-height: 50px;
            text-align: center;
            font-weight: 700;
            font-size: 20px;
          }
          .sudu-item.active {
            background-color: #E6A23C;
            color: #fff;
          }
          .wait-number {display: block;width: 100%;margin: 0 auto;}
          .wait-number .number-ul{
            list-style: none;
            text-align: center;
            width: auto;
            display: flex;
            justify-content: center;
            padding: 0;
            margin-top: 20px;
          }
          .wait-number .number-ul li{
            float: left; width: 50px;
            height: 50px;
            box-sizing: border-box;
            border-top: 1px solid #ddd;
            border-right: 1px solid #ddd;
            border-bottom: 1px solid #ddd;
            float: left;
            cursor: pointer;
            line-height: 50px;
            text-align: center;
            font-weight: 700;
            font-size: 20px;
          }
          .wait-number .number-ul :first-child{
            border-left: 1px solid #ddd;
          }
          .wait-number .number-ul li:hover{
            background-color: #909399;
            color: #fff;
          }
          .wait-number .number-ul li.active{
            background-color: #E6A23C;
            color: #fff;
          }
    
        </style>
      </head>
      <body>
    
        <div class="container">
          <div class="flex-center">
            <div class="sudu-container">
              <div class="sudu-items-container" id="J_sudu_items">
                <!-- <div class="sudu-item" data-index="0"></div> -->
              </div>
            </div>
          </div>
          <div class="wait-number">
            <ul class="number-ul" id="J_number_ul">
              <li>1</li>
              <li>2</li>
              <li>3</li>
              <li>4</li>
              <li>5</li>
              <li>6</li>
              <li>7</li>
              <li>8</li>
              <li>9</li>
            </ul>
          </div>
        </div>
    
        <script src="./index.js"></script>
        <script>
    // 产出一个正确的数独数组
    function createShuDuArr () {
      let arr = [], finArr = [];
      for(let i = 1; i < 10; i ++) {
        arr.push(i)
      }
      finArr = new Array(9).fill(arr)
      return finArr.flat()
    }
          let currentIndex = null
          let correctArr = createShuDuArr()
          console.log(correctArr)
          let suduDataArr = new Array(81).fill(null)
          let suduContainerEl = document.querySelector("#J_sudu_items")
          let suduItem = [] // new Array(81).fill('<div class="sudu-item"></div>')
          for(let i = 0; i < 81; i++) {
            suduItem.push(`<div class="sudu-item" data-index="${i}"></div>`)
          }
          suduContainerEl.innerHTML = suduItem.join('\n')
    
          suduDataArr[1] = 1
          suduDataArr[20] = 5
          suduDataArr[30] = 3
    
          suduDataArr.forEach((outerItem, outerIndex) => {
            if (outerItem) {
              suduContainerEl.querySelector(`.sudu-item:nth-child(${outerIndex+1})`).innerHTML = outerItem
            }
          })
    
          // 初始化数据
          function initData () {
    
          }
    
          // 渲染数据到view
          function renderDataOnView () {
    
          }
    
          // 点击底部数字
          function clickNumberItem (even) {
            let targetEl = even.target
            suduContainerEl.querySelector(`.sudu-item:nth-child(${ currentIndex + 1})`).innerHTML = targetEl.innerHTML
            if(targetEl.innerHTML !== correctArr[currentIndex]) {
              console.log('错误')
            }
            // 验证 当前currentIndex 是否是正确的数字
            // 需要验证suduDataArr是否是数独
          }
    
          // 点击数独区域
          function clickSuduNumberItem (even) {
            let targetEl = even.target
            if(!targetEl.classList.contains('active')) {
              let activeItem = document.querySelector("#J_sudu_items .active")
              if(activeItem && activeItem.classList.contains('active')) {
                activeItem.classList.remove('active')
              }
              targetEl.classList.add('active')
            }
            currentIndex = parseInt(targetEl.dataset.index, 10)
          }
    
          document.querySelector("#J_number_ul").addEventListener('click', clickNumberItem, false)
    
          document.querySelector("#J_sudu_items").addEventListener('click', clickSuduNumberItem, false)
    
    
        </script>
      </body>
    
      </html>

     

    复习了以下知识,

    classList的remove, add,contains

    css中 flex, box-sizing , :nth-clild, :nth-clild(9n)

    new Array(10).fill('<div>123</div>')

    addEventListener(evenName, func, Bloean)

     

    展开全文
  • 本文主要介绍了C++语言和蓝图语言以及他们在虚幻4引擎中...采用回溯算法生成数独矩阵,结合鼠标、键盘、VR手柄等设备进行交互,实现了基本的游戏体验,完成了《虚幻数独数独游戏的开发和对数独唯一解的简单测试。
  • 题目描述: 判断一个9x9 的数独是否有效。...最简单的方式就是遍历三次: Ⅰ 第一次遍历判断每行是否有相同的数 Ⅱ 第二遍遍历判断每列是否有相同的数 Ⅲ 第三遍遍历判断每个方格是否有相同的数 ...

    题目描述:

    判断一个 9x9 的数独是否有效。只需要根据以下规则,验证已经填入的数字是否有效即可。

    数字 1-9 在每一行只能出现一次。
    数字 1-9 在每一列只能出现一次。
    数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。

    上图是一个部分填充的有效的数独。

    数独部分空格内已填入了数字,空白格用 '.' 表示


    方案一:

    最简单的方式就是遍历三次:

    Ⅰ 第一次遍历判断每行是否有相同的数

    Ⅱ 第二遍遍历判断每列是否有相同的数

    Ⅲ 第三遍遍历判断每个方格是否有相同的数

     

    方案二:

    将方案一的三次遍历通过一次遍历完成,针对每次所遍历到的borad[i][j] ,都要判断他所在行、列、小方格有无重复数出现

    如果判断?

    Ⅰ 通过哈希表对每个行列以及小方格计数,

    Ⅱ 如果任一判断大于1,返回false;否则退出循环,饭后true。

    class Solution {
        public boolean isValidSudoku(char[][] board) {
            //初始化数据
            HashMap<Integer,Integer>[] rows = new HashMap[9];
            HashMap<Integer,Integer>[] columns = new HashMap[9];
            HashMap<Integer,Integer>[] boxes = new HashMap[9];
            for(int i = 0;i < 9; i++){
                rows[i] = new HashMap<Integer,Integer>();
                columns[i] = new HashMap<Integer,Integer>();
                boxes[i] = new HashMap<Integer,Integer>();
            }
    
            //遍历
            for(int i = 0; i < 9; i++)
                for(int j = 0; j < 9; j++){
                    if(board[i][j]!='.'){
                        int value = (int)board[i][j];
                        //计数,{value:个数,....}
                        rows[i].put(value,rows[i].getOrDefault(value,0)+1);
                        columns[j].put(value,columns[j].getOrDefault(value,0)+1);
                        boxes[(i/3)*3+j/3].put(value,boxes[(i/3)*3+j/3].getOrDefault(value,0)+1);
    
                        //判断
                        if(rows[i].get(value) > 1 || columns[j].get(value) > 1 || boxes[(i/3)*3+j/3].get(value) > 1)
                        return false;
                    }
                }
            return true;
        }
        
    }

     

    展开全文
  • Matlab GUI 数独游戏

    千次阅读 2020-03-17 15:55:27
    利用Matlab GUI 实现数独游戏,由于还是matlab小白,目前只能实现最简单的功能。 第一步:在命令行输入guide,利用拖动控件的方式设计GUI界面。用到控件有81个可编辑文本、3个按钮、6个单选按钮(因为我只做了6关,...

    利用Matlab GUI 实现数独游戏,由于还是matlab小白,目前只能实现最简单的功能。

    第一步:在命令行输入guide,利用拖动控件的方式设计GUI界面。用到控件有81个可编辑文本、3个按钮、6个单选按钮(因为我只做了6关,所以是6个单选按钮,根据需要游戏关数也可以自己增加)和1个按钮组。
    第二步:编写显示数独题目的barrier函数、显示结果的result函数、以及清空文本的clearout函数。
    第三步:编写单选按钮组、开始按钮、完成按钮及退出按钮的回调函数。

    数独游戏界面如下图:
    在这里插入图片描述
    第一关数独游戏题目如下图:
    在这里插入图片描述
    第一关数独游戏结果如下图:
    填写数字后,点击完成按钮,数字为蓝色表示填写正确,数字为红色表示填写错误。
    在这里插入图片描述
    由于上传不了文件(需要所有程序的可以私信,免费发送),每关的程序都是固定模板,以第六关为例(可编辑文本edit正常应该是1…81,因为我设计界面时删除了一部分,所以程序里出现的是edit1、14、15…93):
    显示数独题目的barrier函数

    function barrier6 ( hObject, eventdata, handles )
    % 第六关题目
    clearout(hObject, eventdata, handles );
    set(handles.edit1,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit14,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit15,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit16,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit17,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit18,'string','6','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit19,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit20,'string','4','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit21,'string','3','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit22,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit23,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit24,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit25,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit26,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit27,'string','7','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit28,'string','1','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit29,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit30,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit31,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit32,'string','2','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit33,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit34,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit35,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit36,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit37,'string','9','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit38,'string','8','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit39,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit40,'string','4','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit41,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit42,'string','2','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit43,'string','7','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit44,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit45,'string','1','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit46,'string','3','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit47,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit48,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit49,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit50,'string','1','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit51,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit52,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit53,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit54,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit55,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit56,'string','7','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit57,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit58,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit59,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit60,'string','6','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit61,'string','4','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit62,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit63,'string','9','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit64,'string','2','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit65,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit66,'string','5','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit67,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit68,'string','9','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit69,'string','8','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit70,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit71,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit72,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit73,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit74,'string','3','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit75,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit76,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit77,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit78,'string','5','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit79,'string','3','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit80,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit81,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit82,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit83,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit84,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit85,'string','7','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit86,'string','3','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit87,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit88,'string','1','FontSize',20,'FontWeight','bold','ForegroundColor','k');
    set(handles.edit89,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit90,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit91,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit92,'string','','FontSize',14,'FontWeight','normal');
    set(handles.edit93,'string','','FontSize',14,'FontWeight','normal');
    end
    

    显示结果的result函数

    function result6 (hObject, eventdata, handles )
    % 第六关结果 
    a=[9 8 7 2 1 6 5 4 3 5 4 3 9 8 7 1 6 2 6 2 1 5 4 3 9 8 7 4 5 2 7 6 1 3 9 8 3 1 9 8 2 5 6 7 4 8 7 6 4 3 9 2 1 5 2 9 8 6 5 4 7 3 1 1 6 5 3 7 8 4 2 9 7 3 4 1 9 2 8 5 6];
    a0=[0 0 0 0 0 6 0 4 3 0 0 0 0 0 7 1 0 0 0 2 0 0 0 0 9 8 0 4 0 2 7 0 1 3 0 0 0 1 0 0 0 0 0 7 0 0 0 6 4 0 9 2 0 5 0 9 8 0 0 0 0 3 0 0 0 5 3 0 0 0 0 0 7 3 0 1 0 0 0 0 0];
    b=a-a0; %a0为题目,a为答案
    n=1;
    for m=1:81
        e=find(b>0); %要填的数字的位置
    if b(m)>0
        c(n)=b(m); %要填的数字
        n=n+1;
    end
    end
    d1=size(c,2); %要填的数字个数
    d=81-d1; %题目的数字个数
    
    i=0; %累计正确的数字
    j=0; %累计填写的数字
    guess1 = str2num(get(handles.edit1,'String'));
    if guess1 == a(1)
        i=i+1;
    elseif guess1 > 0
        j=j+1;
    end
    guess2 = str2num(get(handles.edit14,'String'));
    if guess2 == a(2)
        i=i+1;
    elseif guess2 > 0
        j=j+1;
    end
    guess3 = str2num(get(handles.edit15,'String'));
    if guess3 == a(3)
        i=i+1;
    elseif guess3 > 0
        j=j+1;
    end
    guess4 = str2num(get(handles.edit16,'String'));
    if guess4 == a(4)
        i=i+1;
    elseif guess4 > 0
        j=j+1;
    end
    guess5 = str2num(get(handles.edit17,'String'));
    if guess5 == a(5)
        i=i+1;
    elseif guess5 > 0
        j=j+1;
    end
    guess6 = str2num(get(handles.edit18,'String'));
    if guess6 == a(6)
        i=i+1;
    elseif guess6 > 0
        j=j+1;
    end
    guess7 = str2num(get(handles.edit19,'String'));
    if guess7 == a(7)
        i=i+1;
    elseif guess7 > 0
        j=j+1;
    end
    guess8 = str2num(get(handles.edit20,'String'));
    if guess8 == a(8)
        i=i+1;
    elseif guess8 > 0
        j=j+1;
    end        
    guess9 = str2num(get(handles.edit21,'String'));
    if guess9 == a(9)
        i=i+1;
    elseif guess9 > 0
        j=j+1;
    end
    guess10 = str2num(get(handles.edit22,'String'));
    if guess10 == a(10)
        i=i+1;
    elseif guess10 > 0
        j=j+1;
    end
    guess11 = str2num(get(handles.edit23,'String'));
    if guess11 == a(11)
        i=i+1;
    elseif guess11 > 0
        j=j+1;
    end        
    guess12 = str2num(get(handles.edit24,'String'));
    if guess12 == a(12)
        i=i+1;
    elseif guess12 > 0
        j=j+1;
    end 
    guess13 = str2num(get(handles.edit25,'String'));
    if guess13 == a(13)
        i=i+1;
    elseif guess13 > 0
        j=j+1;
    end
    guess14 = str2num(get(handles.edit26,'String'));
    if guess14 == a(14)
        i=i+1;
    elseif guess14 > 0
        j=j+1;
    end
    guess15 = str2num(get(handles.edit27,'String'));
    if guess15 == a(15)
        i=i+1;
    elseif guess15 > 0
        j=j+1;
    end
    guess16 = str2num(get(handles.edit28,'String'));
    if guess16 == a(16)
        i=i+1;
    elseif guess16 > 0
        j=j+1;
    end        
    guess17 = str2num(get(handles.edit29,'String'));
    if guess17 == a(17)
        i=i+1;
    elseif guess17 > 0
        j=j+1;
    end        
    guess18 = str2num(get(handles.edit30,'String'));
    if guess18 == a(18)
        i=i+1;
    elseif guess18 > 0
        j=j+1;
    end        
    guess19 = str2num(get(handles.edit31,'String'));
    if guess19 == a(19)
        i=i+1;
    elseif guess19 > 0
        j=j+1;
    end
    guess20 = str2num(get(handles.edit32,'String'));
    if guess20 == a(20)
        i=i+1;
    elseif guess20 > 0
        j=j+1;
    end
    guess21 = str2num(get(handles.edit33,'String'));
    if guess21 == a(21)
        i=i+1;
    elseif guess21 > 0
        j=j+1;
    end
    guess22 = str2num(get(handles.edit34,'String'));
    if guess22 == a(22)
        i=i+1;
    elseif guess22 > 0
        j=j+1;
    end        
    guess23 = str2num(get(handles.edit35,'String'));
    if guess23 == a(23)
        i=i+1;
    elseif guess23 > 0
        j=j+1;
    end        
    guess24 = str2num(get(handles.edit36,'String'));
    if guess24 == a(24)
        i=i+1;
    elseif guess24 > 0
        j=j+1;
    end        
    guess25 = str2num(get(handles.edit37,'String'));
    if guess25 == a(25)
        i=i+1;
    elseif guess25 > 0
        j=j+1;
    end 
    guess26 = str2num(get(handles.edit38,'String'));
    if guess26 == a(26)
        i=i+1;
    elseif guess26 > 0
        j=j+1;
    end
    guess27 = str2num(get(handles.edit39,'String'));
    if guess27 == a(27)
        i=i+1;
    elseif guess27 > 0
        j=j+1;
    end 
    guess28 = str2num(get(handles.edit40,'String'));
    if guess28 == a(28)
        i=i+1;
    elseif guess28 > 0
        j=j+1;
    end
    guess29 = str2num(get(handles.edit41,'String'));
    if guess29 == a(29)
        i=i+1;
    elseif guess29 > 0
        j=j+1;
    end        
    guess30 = str2num(get(handles.edit42,'String'));
    if guess30 == a(30)
        i=i+1;
    elseif guess30 > 0
        j=j+1;
    end
    guess31 = str2num(get(handles.edit43,'String'));
    if guess31 == a(31)
        i=i+1;
    elseif guess31 > 0
        j=j+1;
    end  
    guess32 = str2num(get(handles.edit44,'String'));
    if guess32 == a(32)
        i=i+1;
    elseif guess32 > 0
        j=j+1;
    end
    guess33 = str2num(get(handles.edit45,'String'));
    if guess33 == a(33)
        i=i+1;
    elseif guess33 > 0
        j=j+1;
    end        
    guess34 = str2num(get(handles.edit46,'String'));
    if guess34 == a(34)
        i=i+1;
    elseif guess34 > 0
        j=j+1;
    end        
    guess35 = str2num(get(handles.edit47,'String'));
    if guess35 == a(35)
        i=i+1;
    elseif guess35 > 0
        j=j+1;
    end 
    guess36 = str2num(get(handles.edit48,'String'));
    if guess36 == a(36)
        i=i+1;
    elseif guess36 > 0
        j=j+1;
    end
    guess37 = str2num(get(handles.edit49,'String'));
    if guess37 == a(37)
        i=i+1;
    elseif guess37 > 0
        j=j+1;
    end
    guess38 = str2num(get(handles.edit50,'String'));
    if guess38 == a(38)
        i=i+1;
    elseif guess38 > 0
        j=j+1;
    end        
    guess39 = str2num(get(handles.edit51,'String'));
    if guess39 == a(39)
        i=i+1;
    elseif guess39 > 0
        j=j+1;
    end 
    guess40 = str2num(get(handles.edit52,'String'));
    if guess40 == a(40)
        i=i+1;
    elseif guess40 > 0
        j=j+1;
    end
    guess41 = str2num(get(handles.edit53,'String'));
    if guess41 == a(41)
        i=i+1;
    elseif guess41 > 0
        j=j+1;
    end    
    guess42 = str2num(get(handles.edit54,'String'));
    if guess42 == a(42)
        i=i+1;
    elseif guess42 > 0
        j=j+1;
    end
    guess43 = str2num(get(handles.edit55,'String'));
    if guess43 == a(43)
        i=i+1;
    elseif guess43 > 0
        j=j+1;
    end        
    guess44 = str2num(get(handles.edit56,'String'));
    if guess44 == a(44)
        i=i+1;
    elseif guess44 > 0
        j=j+1;
    end    
    guess45 = str2num(get(handles.edit57,'String'));
    if guess45 == a(45)
        i=i+1;
    elseif guess45 > 0
        j=j+1;
    end
    guess46 = str2num(get(handles.edit58,'String'));
    if guess46 == a(46)
        i=i+1;
    elseif guess46 > 0
        j=j+1;
    end
    guess47 = str2num(get(handles.edit59,'String'));
    if guess47 == a(47)
        i=i+1;
    elseif guess47 > 0
        j=j+1;
    end        
    guess48 = str2num(get(handles.edit60,'String'));
    if guess48 == a(48)
        i=i+1;
    elseif guess48 > 0
        j=j+1;
    end
    guess49 = str2num(get(handles.edit61,'String'));
    if guess49 == a(49)
        i=i+1;
    elseif guess49 > 0
        j=j+1;
    end 
    guess50 = str2num(get(handles.edit62,'String'));
    if guess50 == a(50)
        i=i+1;
    elseif guess50 > 0
        j=j+1;
    end
    guess51 = str2num(get(handles.edit63,'String'));
    if guess51 == a(51)
        i=i+1;
    elseif guess51 > 0
        j=j+1;
    end        
    guess52 = str2num(get(handles.edit64,'String'));
    if guess52 == a(52)
        i=i+1;
    elseif guess52 > 0
        j=j+1;
    end        
    guess53 = str2num(get(handles.edit65,'String'));
    if guess53 == a(53)
        i=i+1;
    elseif guess53 > 0
        j=j+1;
    end   
    guess54 = str2num(get(handles.edit66,'String'));
    if guess54 == a(54)
        i=i+1;
    elseif guess54 > 0
        j=j+1;
    end
    guess55 = str2num(get(handles.edit67,'String'));
    if guess55 == a(55)
        i=i+1;
    elseif guess55 > 0
        j=j+1;
    end 
    guess56 = str2num(get(handles.edit68,'String'));
    if guess56 == a(56)
        i=i+1;
    elseif guess56 > 0
        j=j+1;
    end
    guess57 = str2num(get(handles.edit69,'String'));
    if guess57 == a(57)
        i=i+1;
    elseif guess57 > 0
        j=j+1;
    end        
    guess58 = str2num(get(handles.edit70,'String'));
    if guess58 == a(58)
        i=i+1;
    elseif guess58 > 0
        j=j+1;
    end        
    guess59 = str2num(get(handles.edit71,'String'));
    if guess59 == a(59)
        i=i+1;
    elseif guess59 > 0
        j=j+1;
    end        
    guess60 = str2num(get(handles.edit72,'String'));
    if guess60 == a(60)
        i=i+1;
    elseif guess60 > 0
        j=j+1;
    end   
    guess61 = str2num(get(handles.edit73,'String'));
    if guess61 == a(61)
        i=i+1;
    elseif guess61 > 0
        j=j+1;
    end
    guess62 = str2num(get(handles.edit74,'String'));
    if guess62 == a(62)
        i=i+1;
    elseif guess62 > 0
        j=j+1;
    end
    guess63 = str2num(get(handles.edit75,'String'));
    if guess63 == a(63)
        i=i+1;
    elseif guess63 > 0
        j=j+1;
    end        
    guess64 =str2num(get(handles.edit76,'String'));
    if guess64 == a(64)
        i=i+1;
    elseif guess64 > 0
        j=j+1;
    end        
    guess65 = str2num(get(handles.edit77,'String'));
    if guess65 == a(65)
        i=i+1;
    elseif guess65 > 0
        j=j+1;
    end        
    guess66 = str2num(get(handles.edit78,'String'));
    if guess66 == a(66)
        i=i+1;
    elseif guess66 > 0
        j=j+1;
    end
    guess67 = str2num(get(handles.edit79,'String'));
    if guess67 == a(67)
        i=i+1;
    elseif guess67 > 0
        j=j+1;
    end
    guess68 = str2num(get(handles.edit80,'String'));
    if guess68 == a(68)
        i=i+1;
    elseif guess68 > 0
        j=j+1;
    end
    guess69 = str2num(get(handles.edit81,'String'));
    if guess69 == a(69)
        i=i+1;
    elseif guess69 > 0
        j=j+1;
    end
    guess70 = str2num(get(handles.edit82,'String'));
    if guess70 == a(70)
        i=i+1;
    elseif guess70 > 0
        j=j+1;
    end        
    guess71 = str2num(get(handles.edit83,'String'));
    if guess71 == a(71)
        i=i+1;
    elseif guess71 > 0
        j=j+1;
    end  
    guess72 =str2num(get(handles.edit84,'String'));
    if guess72 == a(72)
        i=i+1;
    elseif guess72 > 0
        j=j+1;
    end
    guess73 =str2num(get(handles.edit85,'String'));
    if guess73 == a(73)
        i=i+1;
    elseif guess73 > 0
        j=j+1;
    end        
    guess74 =str2num(get(handles.edit86,'String'));
    if guess74 == a(74)
        i=i+1;
    elseif guess74 > 0
        j=j+1;
    end        
    guess75 = str2num(get(handles.edit87,'String'));
    if guess75 == a(75)
        i=i+1;
    elseif guess75 > 0
        j=j+1;
    end        
    guess76 = str2num(get(handles.edit88,'String'));
    if guess76 == a(76)
        i=i+1;
    elseif guess76 > 0
        j=j+1;
    end    
    guess77 = str2num(get(handles.edit89,'String'));
    if guess77 == a(77)
        i=i+1;
    elseif guess77 > 0
        j=j+1;
    end
    guess78 =str2num(get(handles.edit90,'String'));
    if guess78 == a(78)
        i=i+1;
    elseif guess78 > 0
        j=j+1;
    end
    guess79 = str2num(get(handles.edit91,'String'));
    if guess79 == a(79)
        i=i+1;
    elseif guess79 > 0
        j=j+1;
    end
    guess80 = str2num(get(handles.edit92,'String'));
    if guess80 == a(80)
        i=i+1;
    elseif guess80 > 0
        j=j+1;
    end
    guess81 = str2num(get(handles.edit93,'String'));
    if guess81 == a(81)
        i=i+1;
    elseif guess81 > 0
        j=j+1;
    end
    
    if i==d && j==0
        h = msgbox('请填写数字!');
        uiwait(h);
    elseif i<d  
        h = msgbox('请不要改题目!');
        uiwait(h);
        clearout(hObject, eventdata, handles );
    elseif i==81  %填写的数字全部正确
        h = msgbox('顺利过关!');
        uiwait(h);
        clearout(hObject, eventdata, handles );
    elseif j>=0   %=0时表示填写的数字正确,>0时表示填写的数字有错误,并将错误的数字改正确
        if guess1 ~= c(1)
            set(handles.edit1,'string','9','ForegroundColor','r');
        end
        if guess2 ~= c(2)
            set(handles.edit14,'string','8','ForegroundColor','r');
        end
        if guess3 ~= c(3)
            set(handles.edit15,'string','7','ForegroundColor','r');
        end
        if guess4 ~= c(4)
            set(handles.edit16,'string','2','ForegroundColor','r');
        end
        if guess5 ~= c(5)
            set(handles.edit17,'string','1','ForegroundColor','r');
        end
        if guess7 ~= c(6)
            set(handles.edit19,'string','5','ForegroundColor','r');
        end
        if guess10 ~= c(7)
            set(handles.edit22,'string','5','ForegroundColor','r');
        end
        if guess11 ~= c(8)
            set(handles.edit23,'string','4','ForegroundColor','r');
        end
        if guess12 ~= c(9)
            set(handles.edit24,'string','3','ForegroundColor','r');
        end
        if guess13 ~= c(10)
            set(handles.edit25,'string','9','ForegroundColor','r');
        end
        if guess14 ~= c(11)
            set(handles.edit26,'string','8','ForegroundColor','r');
        end
        if guess17 ~= c(12)
            set(handles.edit29,'string','6','ForegroundColor','r');
        end
        if guess18 ~= c(13)
            set(handles.edit30,'string','2','ForegroundColor','r');
        end
        if guess19 ~= c(14)
            set(handles.edit31,'string','6','ForegroundColor','r');
        end
        if guess21 ~= c(15)
            set(handles.edit33,'string','1','ForegroundColor','r');
        end
        if guess22 ~= c(16)
            set(handles.edit34,'string','5','ForegroundColor','r');
        end
        if guess23 ~= c(17)
            set(handles.edit35,'string','4','ForegroundColor','r');
        end
        if guess24 ~= c(18)
            set(handles.edit36,'string','3','ForegroundColor','r');
        end
        if guess27 ~= c(19)
            set(handles.edit39,'string','7','ForegroundColor','r');
        end
        if guess29 ~= c(20)
            set(handles.edit41,'string','5','ForegroundColor','r');
        end
        if guess32 ~= c(21)
            set(handles.edit44,'string','6','ForegroundColor','r');
        end
        if guess35 ~= c(22)
            set(handles.edit47,'string','9','ForegroundColor','r');
        end
        if guess36 ~= c(23)
            set(handles.edit48,'string','8','ForegroundColor','r');
        end
        if guess37 ~= c(24)
            set(handles.edit49,'string','3','ForegroundColor','r');
        end
        if guess39 ~= c(25)
            set(handles.edit51,'string','9','ForegroundColor','r');
        end
        if guess40 ~= c(26)
            set(handles.edit52,'string','8','ForegroundColor','r');
        end
        if guess41 ~= c(27)
            set(handles.edit53,'string','2','ForegroundColor','r');
        end
        if guess42 ~= c(28)
            set(handles.edit54,'string','5','ForegroundColor','r');
        end
        if guess43 ~= c(29)
            set(handles.edit55,'string','6','ForegroundColor','r');
        end
        if guess45 ~= c(30)
            set(handles.edit57,'string','4','ForegroundColor','r');
        end
        if guess46 ~= c(31)
            set(handles.edit58,'string','8','ForegroundColor','r');
        end
        if guess47 ~= c(32)
            set(handles.edit59,'string','7','ForegroundColor','r');
        end
        if guess50 ~= c(33)
            set(handles.edit62,'string','3','ForegroundColor','r');
        end
        if guess53 ~= c(34)
            set(handles.edit65,'string','1','ForegroundColor','r');
        end
        if guess55 ~= c(35)
            set(handles.edit67,'string','2','ForegroundColor','r');
        end
        if guess58 ~= c(36)
            set(handles.edit70,'string','6','ForegroundColor','r');
        end
        if guess59 ~= c(37)
            set(handles.edit71,'string','5','ForegroundColor','r');
        end
        if guess60 ~= c(38)
            set(handles.edit72,'string','4','ForegroundColor','r');
        end
        if guess61 ~= c(39)
            set(handles.edit73,'string','7','ForegroundColor','r');
        end
        if guess63 ~= c(40)
            set(handles.edit75,'string','1','ForegroundColor','r');
        end
        if guess64 ~= c(41)
            set(handles.edit76,'string','1','ForegroundColor','r');
        end
        if guess65 ~= c(42)
            set(handles.edit77,'string','6','ForegroundColor','r');
        end  
        if guess68 ~= c(43)
            set(handles.edit80,'string','7','ForegroundColor','r');
        end 
        if guess69 ~= c(44)
            set(handles.edit81,'string','8','ForegroundColor','r');
        end
        if guess70 ~= c(45)
            set(handles.edit82,'string','4','ForegroundColor','r');
        end    
        if guess71 ~= c(46)
            set(handles.edit83,'string','2','ForegroundColor','r'); 
        end
        if guess72 ~= c(47)
            set(handles.edit84,'string','9','ForegroundColor','r');
        end
        if guess75 ~= c(48)
            set(handles.edit87,'string','4','ForegroundColor','r');
        end
        if guess77 ~= c(49)
            set(handles.edit89,'string','9','ForegroundColor','r');
        end
        if guess78 ~= c(50)
            set(handles.edit90,'string','2','ForegroundColor','r');
        end
        if guess79 ~= c(51)
            set(handles.edit91,'string','8','ForegroundColor','r');
        end
        if guess80 ~= c(52)
            set(handles.edit92,'string','5','ForegroundColor','r');
        end
        if guess81 ~= c(53)
            set(handles.edit93,'string','6','ForegroundColor','r');
        end    
    
        h = msgbox('请继续努力!');
        uiwait(h);
        clearout(hObject, eventdata, handles );
    end
    
    end
    

    清空可编辑文本的clearout函数

    function clearout(hObject, eventdata, handles )
    % 清空
    % 'BacbgroundColor','w'表示可输入文本框的背景颜色改为白色
    % 'FontWeight','normal'表示字体正常
    set(handles.edit1,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit14,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit15,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit16,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit17,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit18,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit19,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit20,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit21,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit22,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit23,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit24,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit25,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit26,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit27,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit28,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit29,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit30,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit31,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit32,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit33,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit34,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit35,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit36,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit37,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit38,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit39,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit40,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit41,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit42,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit43,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit44,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit45,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit46,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit47,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit48,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit49,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit50,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit51,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit52,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit53,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit54,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit55,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit56,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit57,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit58,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit59,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit60,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit61,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit62,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit63,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit64,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit65,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit66,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit67,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit68,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit69,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit70,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit71,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit72,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit73,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit74,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit75,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit76,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit77,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit78,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit79,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit80,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit81,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit82,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit83,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit84,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit85,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit86,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit87,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit88,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit89,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit90,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit91,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit92,'string','','ForegroundColor','b','FontWeight','normal');
    set(handles.edit93,'string','','ForegroundColor','b','FontWeight','normal');
    end
    

    单选按钮组回调函数下面的程序:

    global how
    str=get(hObject,'tag');
    switch str
        case 'radiobutton1'
            how=1;
        case 'radiobutton2'
            how=2;
        case 'radiobutton3'
            how=3;
        case 'radiobutton4'
            how=4;      
        case 'radiobutton5'
            how=5;       
        case 'radiobutton6'
            how=6;            
    end
    

    开始按钮回调函数下面的程序:

    global how
    if how == 1
        barrier1( hObject, eventdata, handles )
    elseif how == 2
        barrier2( hObject, eventdata, handles )  
    elseif how == 3
        barrier3( hObject, eventdata, handles )      
    elseif how == 4
        barrier4( hObject, eventdata, handles )       
    elseif how == 5
        barrier5( hObject, eventdata, handles )
    elseif how == 6
        barrier6( hObject, eventdata, handles )    
    end
    

    完成按钮回调函数下面的程序:

    global how
    if how == 1
        result1(hObject, eventdata, handles )
    elseif how == 2
        result2(hObject, eventdata, handles )   
    elseif how == 3
        result3(hObject, eventdata, handles )       
    elseif how == 4
        result4(hObject, eventdata, handles )       
    elseif how == 5
        result5(hObject, eventdata, handles )
    elseif how == 6
        result6(hObject, eventdata, handles )     
    end
    

    退出按钮回调函数下面的程序:

    close(gcf);%退出界面
    

    参考文献:
    编写一个简单的GUI
    单选按钮和按钮组

    展开全文
  • 这个涉及HTML、CSS与JS基础知识,想制作,也不是很难,算是个非常简单易懂小程序。首先我们需要在网上找到一个数独题目,并将它完成。本教程为了节约时间,我们只需要做左上角那一块九宫格,也就是这九个格子...

    这个涉及HTML、CSS与JS的基础知识,想制作,也不是很难,算是个非常简单易懂的小程序。

    首先我们需要在网上找到一个数独题目,并将它完成。

    本教程为了节约时间,我们只需要做左上角那一块的九宫格,也就是这九个格子。

    首先先来解决HTML与CSS的部分,这一部分的思路很简单,首先我们要做出一个3X3的表格,在相应的格子中填入固定数字,在需要填写答案的格子中插入输入框,并设置ID,最后加上一个【完成按钮】。理解思路之后再做就很容易了。

    ?  制作3X3的表格,并填入数字。代码如下(如果看不清图上的字可以跳到下面看完整文字版的代码):

    完成之后建议尝试运行一下,确认数字所在的格子没有错误。此时的表格并非好看的正方形,但不用在意,之后会变得好看的。

    ?  在空白的格子中插入标签,并设置ID与其他参数。个人使用的代码如下:,小姐姐们可以根据自己情况来更改详细参数,标签的ID建议对应九宫格本身的编号。

    ?  接下来插入按钮标签。

    到此门面的工作已经完成,接下来是JS的部分。就像这样:

    这一段代码的作用是获取每一个输入框中的数值,因为重复性很高所以十分容易眼花出错,请在这个地方多加注意。

    这一段的意思大概是当达成某个条件时,执行指令1,否则执行指令2。第一个括号中就是我们要设置的条件,在这个地方我们要为每一个空格子设定他们的正确答案,每个值之间要用 & 来连接。这个地方也很容易出错,所以请多加注意。

    完成啦~赶紧运行看看吧~如果有什么不对或者不明白的地方,欢迎提出来~

    展开全文
  • Android 九宫格 数独游戏,生成随机... 这个简单的Android数独游戏,只是帮助打基础的,源码里面的注释还是比较多的,您最好下载本源码包解压后查看代码文件。里面涉及到界面、数组 、随机数、算法 等各个方面的技巧。
  • 关于数独游戏的实现(一)

    千次阅读 2018-04-08 20:52:27
    1)Github项目网址:https://github.com/1120161970/sudoku2)PSP表格:3)解题思路:首先,生成数独最简单想到方法就是BFS爆搜就行了,然后优化话加一些判断和多线程应该可以。至于结构之类,先去网上看看...
  • react-native还是蛮火的,前面用它做了一个火车票查询的,感觉还可以,...先生成一张完整的数独表,再去扣掉一些数字,最后变成题目。 我是先行后列去一格一格去放数字的,先放第一行,这个直接打乱顺序放入就可以。然
  • [TOC] 任务总体目标:实现一个能够生成数独游戏并求解数独问题的控制台程序 具体要求 ...回溯法通常用最简单的递归方法来实现,在反复重复上述的步骤后可能出现两种情况: 找到一个可能存在的正确的答
  • 1.数独游戏(生成题目解唯一)

    万次阅读 多人点赞 2018-09-06 16:40:53
    前几天在玩数独游戏的时候,产生了一个大胆想法: 数独app上题目都是现成,干脆自己写一个可以随机生成数独程序算了 一、需求提出: 1.随机生成数独题目,要求该题目有解(有一个解最好); 2.当填...
  • 我自己做的数独游戏,做了一些简单的登录和注册玩家,然后就是通关后继续下一关。最后有个玩家通关信息记录
  • 【例题2】数独游戏 题目 题解 经过不断地debug,终于用自己方法做出这题了。 我方法跟书上不同,自认为更简单些。 用三个二维数组分别记录每一行、列、宫中是否出现1~9,即判重,来进行剪枝。 dfs每个输入时...
  • 九宫格数独游戏解法(一)

    千次阅读 2013-07-27 23:45:50
    这是个比较粗略的解法,对于简单的一两次就解掉了,复杂的可能要多运行几次才比较容易得出结果。这个简单程序复杂的地方是要把直观上的三种情况得出三个独立的值,然后取交集,尤其是在同一个循环里边实现第三个...
  • 数独求解

    千次阅读 2014-03-12 22:21:15
    芬兰一位数学家号称设计出全球难的“数独游戏”,并刊登...这位数学家说,他所设计的数独游戏难度等级是十一,可以说是所有数独游戏中,难度最高的等级。     编程求解的方法有两种 穷举罚:穷举法算法简单,但运
  • 数独游戏规则是一种源自18世纪末瑞士的数学智力拼图游戏。拼图是九宫格(即3格宽×3格高)的正方...计算机算法简介本文所讨论的算法是一种通用算法,虽然不能说是快的算法,但却可以求解所有的数独游戏。算法准备:...
  • 数独计划-源码

    2021-02-16 03:30:14
    )//如果您以前从未玩过数独游戏,请尝试《纽约时报》难题版块中简单”难题。 目标 该项目最终目标是创建一个“数独检查器”。 sudoku检查器将是一个接受单个sudoku网格(由数组数组表示)函数,如果该网格...
  • <!-- @page {margin:2cm} p {margin-bottom:0.21cm} a:link {color:#000000; font-size:7pt; ...本来很简单的一件事,直接用java.util.timer应该就够用了,但是发现在它的task中无法去i
  • 数独(DFS)

    千次阅读 2017-02-04 18:05:38
    数独是一个我们都非常熟悉的经典游戏,运用计算机我们可以很快地解开数独难题,现在有一些简单的数独题目,请编写一个程序求解。 输入描述: 输入9行,每行为空格隔开的9个数字,为0的地方就是需要填充的。 输出...
  • 数独求解(DFS)

    2018-08-30 02:29:05
    题目:数独是一个我们都非常熟悉的经典游戏,运用计算机我们可以很快地解开数独难题,现在有一些简单的数独题目,请编写一个程序求解。 思路:从9×9的数独矩阵的第一格开始,一直求解到最后一格。 每一格都遍历 1~...
  • Python(+numpy)实现对9*9数独问题的求解 利用Python(+numpy库)递归实现对9*9...无论是4*4还是9*9的数独游戏规则很简单很粗暴,拿9*9数独来说,规则可概括为 9组 1-9 共 81个数字(包含已给出的数字)填入 9*9 的方格
  • 总共有多少个数独

    2012-05-12 15:31:01
    憋屈地看了一个星期的论文,实在是没一点意思。...喜欢这个自带的游戏的特点,界面简单,只做必要的错误提示,可以回溯,是我用过的理想的数独游戏了,呵呵。至于我自己打算做一个数独游戏,纯粹是为了现学现...
  • 这种游戏全面考验做题者观察能力和推理能力,虽然玩法简单,但数字排列方式却千变万化,所以不少教育者认为数独是训练头脑绝佳方式。 关于数独的算法有很多种,基本有基拙挖掘法,唯一解法,侯选数置换法.查...
  • To 洛谷.1784 数独 类似题:CODEVS.4966 简单数独(4*4数独)CODEVS.2924 数独挑战) 题目描述 数独是根据9×9盘面上已知数字,推理出所有剩余空格数字,并...芬兰一位数学家号称设计出全球数独游戏...
  • 数独(日语:数独すうどく)是一种源自18世纪末瑞士,后在美国发展、并在日本得以发扬光大数学智力拼图游戏。拼图是九宫格(即3格宽×3格高)正方形状,每一...在数独出现之前,流行的游戏有:魔方(Rubik's...
  • 最近迷上了数独

    千次阅读 2006-08-22 10:10:00
    第一次玩数独,在试了两把简单入门级之后,马上开始进入难的级别,感觉挺有挑战的,一玩就玩到凌晨3,4点还浑然不知,慢慢的发现原来简单的数字也能让人如此入迷。遂开始深入思考,如何把数独的规则应用到游戏中去...

空空如也

空空如也

1 2 3 4
收藏数 72
精华内容 28
关键字:

最简单的数独游戏