扒开腿挺进岳湿润的花苞视频|将军边走边挺进她H树林|挺进朋友人妻张婉莹身体|岳脱得精光让我挺进去视频|第一次挺进莹莹的身体里视频|脱岳裙子从后面挺进去视频

新疆軟件開發(fā)

本站首頁 軟件開發(fā) 成功案例 公司新聞 公司簡介 客服中心 軟件技術(shù) 網(wǎng)站建設(shè)
  您現(xiàn)在的位置: 新疆二域軟件開發(fā)公司 >> .Net技術(shù) >> 文章正文

C# Mines(布雷) 代碼

一個(gè)C# Mines(布雷)的 代碼,新手研究一下吧,新疆軟件開發(fā)網(wǎng) m.jdtbank.com

using System.Collections;
using System.IO;
using System;
namespace com.Mines
{
class SearchingMines
{
public ArrayList list = new ArrayList();
public int[,] mines = new int[10, 10];
static void Main(string[] args)
{
SearchingMines sm = new SearchingMines();
sm.initMines();
sm.HidenMines();
sm.FillInOtherNumber();
sm.display();
// sm.SaveTxt();
}
public void initMines()
{
for (int i = 0; i < this.mines.GetLength(0); i++)
{
for (int j = 0; j < this.mines.GetLength(1); j++)
{
this.mines[i, j] = 0;
list.Add(this.mines[i, j]);
}
}
}

public void HidenMines()
{

Random r = new Random();
for (int i = 0; i < 9; i++)
{
int count = this.list.Count;
int number = r.Next(count);
int row = number / 10;
int column = number % 10;
this.mines[row, column] = 9;
this.list.RemoveAt(this.mines[row, column]);
}


}

public void FillInOtherNumber()
{
try
{

for (int i = 0; i < this.mines.GetLength(0); i++)
{
for (int j = 0; j < this.mines.GetLength(1); j++)
{

int left = j - 1;
int right = j + 1;
int top = i - 1;
int bottom = i + 1;
if (this.mines[i, j] != 9)
{
if(top>=0 && left>=0)//左邊和上邊
{
if (this.mines[top, left] == 9)//判斷左上方是否為9
{
mines[i,j] += 1;
}
}
if(top>=0 && right<10)//右邊和上邊
{
if (this.mines[top, right] == 9)//判斷該點(diǎn)的右上方是否
{
mines[i,j] += 1;
}
}
if(top>=0)//最上邊
{
if (this.mines[top, j] == 9)//上邊的那個(gè)是否為9
{
mines[i,j] += 1;
}
}
if(left>=0)//最左邊
{
if (this.mines[i, left] == 9)//看左邊那個(gè)是否為9
{
mines[i,j] += 1;
}
}
if(right<10)//最右邊
{
if (this.mines[i, right] == 9)//看右邊是否為9
{
mines[i,j] += 1;
}
}
if(bottom<10 && left >=0)//底部和左邊
{
if (this.mines[bottom, left] == 9)//左下方是否為9
{
mines[i,j] += 1;
}
}

if(bottom<10 && right<10)//右下方
{
if (this.mines[bottom, right] == 9)右下方
{
mines[i,j] += 1;
}
}
if(bottom<10)//底部
{
if (this.mines[bottom, j] == 9)//底部是否為9
{
mines[i,j] += 1;
}
}

// if (left < 0)//左邊
// {
// if (this.mines[i, right] == 9)//右側(cè)是否為9
// { count += 1; }
// if (bottom < 10 && bottom > 0)//如果底邊的范圍是除過頭節(jié)點(diǎn)和尾節(jié)點(diǎn)
// {
// if (this.mines[bottom, j] == 9)//底部是否為9
// { count += 1; }
// if (this.mines[bottom, right] == 9)//右下是否為9
// { count += 1; }
// }
// if (top > 0 && top < 10)//上邊除過頭結(jié)點(diǎn)和尾節(jié)點(diǎn)
// {
// if (this.mines[top, j] == 9)//頭上那個(gè)點(diǎn)是否為9
// { count += 1; }
// if (this.mines[top, right] == 9)//右上是否為9
// { count += 1; }
// }
// }
// if (j == this.mines.GetLength(0))
// {
// if (i == 0)

// {
// if (this.mines[i, j - 1] == 9)
// { count += 1; }
// if (this.mines[i - 1, j - 1] == 9)
// { count += 1; }
// if (this.mines[i - 1, j] == 9)
// { count += 1; }
//
// }
// if(i>0&&i<this.mines.GetLength(1))
// {
// if(this.mines[i+1,j-1]==9)
// {count+=1;}
// if (this.mines[i + 1, j] == 9)
// { count += 1; }
// if (this.mines[i, j - 1] == 9)
// { count += 1; }
// if (this.mines[i - 1, j] == 9)
// { count += 1; }
// if (this.mines[i - 1, j - 1] == 9)
// { count += 1; }
// }
// if (i == this.mines.GetLength(1))
// {
// if (this.mines[i - 1, j - 1]==9)
// { count += 1; }
// if (this.mines[i - 1, j] == 9)
// { count += 1; }
// if (this.mines[i, j - 1] == 9)
// { count += 1; }
// }
// }


// this.mines[i, j] = count;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

public void display()
{
for (int i = 0; i < this.mines.GetLength(0); i++)
{
for (int j = 0; j < this.mines.GetLength(1); j++)
{
Console.Write(this.mines[i, j] + " ");
}
Console.Write("n");
}

}

public void SaveTxt()
{
StreamWriter sw = new StreamWriter(@"c:abc.txt");
for (int i = 0; i < this.mines.GetLength(0); i++)
{
for (int j = 0; j < this.mines.GetLength(1); j++)
{
sw.Write(this.mines[i, j] + " ");
}
sw.WriteLine();
}
sw.Flush();
sw.Close();

}


}

}


in

作者:未知 | 文章來源:未知 | 更新時(shí)間:2007-11-17 17:16:57

  • 上一篇文章:

  • 下一篇文章:

  • 相關(guān)文章:
    C#實(shí)現(xiàn)短信發(fā)送程序的例子
    .net學(xué)習(xí):c#事件的深入分析
    基礎(chǔ)學(xué)習(xí):java中使用存儲過程
    C#如何設(shè)置或者獲取目錄的權(quán)限?
    解析c#語言和java語言最相似的地方
    C#中如何才能調(diào)用QTP自動化對象
    C#如何轉(zhuǎn)換AVI文件為BMP位圖文件
    c#如何連接各類數(shù)據(jù)庫
    C#abstact interface 學(xué)習(xí)
    c#中的interface abstract與virtual學(xué)習(xí)
    軟件技術(shù)
    · 開發(fā)語言
    · Java技術(shù)
    · .Net技術(shù)
    · 數(shù)據(jù)庫開發(fā)
    最新文章  
    ·.net技術(shù) asp.net MVC3 Vi
    ·.net將視頻文件格式轉(zhuǎn)換成
    ·NET Framework 2.0 Servic
    ·如何動態(tài)修改winform的app
    ·asp,net軟件結(jié)構(gòu)設(shè)計(jì)和相關(guān)
    ·學(xué)習(xí)怎樣使用ASP.NET中的虛
    ·,net基礎(chǔ)類的學(xué)習(xí):system
    ·.net學(xué)習(xí):c#事件的深入分
    ·Facade Pattern學(xué)習(xí)總結(jié)
    ·C#如何設(shè)置或者獲取目錄的
    ·如何使用XSL來定義ASP.NET
    ·理解WCF Data Contract契約
    ·如何能在.net2.0開發(fā)的控件
    ·模式怎樣使用,講解模式的
    ·如何解決Menu菜單被frame遮
    關(guān)于我們 | 軟件開發(fā) | 下載試用 | 客服中心 | 聯(lián)系我們 | 友情鏈接 | 網(wǎng)站地圖 | 新疆電子地圖 | RSS訂閱
    版權(quán)所有 © 2016 新疆二域軟件開發(fā)網(wǎng) m.jdtbank.com All Rights Reserved 新ICP備14003571號
    新疆軟件開發(fā)總機(jī):0991-4842803、4811639.
    客服QQ:596589785 ;地址:新疆烏魯木齊北京中路華聯(lián)大廈A-5C 郵編:830000
     
    永丰县| 长顺县| 宜城市| 乌恰县| 大连市| 林芝县| 淮南市| 大厂| 霍州市| 永丰县| 普兰店市| 汉阴县| 肥城市| 鄂州市| 时尚| 廉江市| 穆棱市| 叶城县| 鸡西市| 厦门市| 淅川县| 郧西县| 北碚区| 连州市| 新泰市| 鱼台县| 黑山县| 靖远县| 长乐市| 溧水县| 竹北市| 尚义县| 安平县| 海林市| 佛坪县| 萨嘎县| 天门市| 堆龙德庆县| 泾源县| 柳州市| 太湖县|