C〓〓〓はWindows XPの持参する雷除去のゲームをまねます
本論文の実例は、皆さんにC〓〓〓仿Windows XPが持参する雷除去ゲームの具体的なコードを共有しました。参考にしてください。具体的な内容は以下の通りです。
1題目の説明:Windows XPの持参する雷除去ゲームを模倣します。
一つの30を定義します×30の二次元配列は、Windows XPが持参した掃海ゲームをまねて、この二次元配列をランダムに配置し、少なくとも30個の雷を必要とする。ゲームのルールは、ある元素の値が1週間の間に存在する地雷の数です。
2ソースコードの詳細
以上が本文の全部です。皆さんの勉強に役に立つように、私たちを応援してください。
1題目の説明:Windows XPの持参する雷除去ゲームを模倣します。
一つの30を定義します×30の二次元配列は、Windows XPが持参した掃海ゲームをまねて、この二次元配列をランダムに配置し、少なくとも30個の雷を必要とする。ゲームのルールは、ある元素の値が1週間の間に存在する地雷の数です。
2ソースコードの詳細
using System;
using System.Collections;
namespace Csharp5_3
{
class Program
{
static void Main(string[] args)
{
ArrayList arrayList = new();
ArrayList arrayList_map = new();
Random rd = new();
for (int i = 0; i < 900; i++)
{
if (rd.Next() % 20 == 0)
{
arrayList.Add(1);
}
else
{
arrayList.Add(0);
}
arrayList_map.Add(0);
}
for (int i = 0; i < 30; i++)
{
for (int j = 0; j < 30; ++j)
{
Console.Write(arrayList[i * 30 + j]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.WriteLine();
for ( int i = 0; i < 30; i ++ )
{
for ( int j = 0; j < 30; j ++ )
{
// ,
//
if (((i - 1) * 30 + j) >= 0 && ((i - 1) * 30 + j) < 900 && j != 0) //
{
if (Convert.ToInt32(arrayList[i * 30 + j - 30]) == 1)
{
arrayList_map[i * 30 + j] = Convert.ToInt32(arrayList[i * 30 + j]) + 1;
}
}
//
if (((i + 1) * 30 + j) >= 0 && ((i + 1) * 30 + j) < 900 && j != 29) //
{
if (Convert.ToInt32(arrayList[i * 30 + j + 30]) == 1)
{
arrayList_map[i * 30 + j] = Convert.ToInt32(arrayList[i * 30 + j]) + 1;
}
}
//
if ((i * 30 + j - 1) >= 0 && (i * 30 + j -1) < 900 && j != 0) //
{
if (Convert.ToInt32(arrayList[i * 30 + j -1]) == 1)
{
arrayList_map[i * 30 + j] = Convert.ToInt32(arrayList[i * 30 + j]) + 1;
}
}
//
if ((i * 30 + j + 1) >= 0 && (i * 30 + j + 1) < 900 && j != 29) //
{
if (Convert.ToInt32(arrayList[i * 30 + j + 1]) == 1)
{
arrayList_map[i * 30 + j] = Convert.ToInt32(arrayList[i * 30 + j]) + 1;
}
}
//
if (((i - 1) * 30 + j -1 ) >= 0 && ((i - 1) * 30 + j - 1) < 900 && j != 0) //
{
if (Convert.ToInt32(arrayList[(i - 1) * 30 + j - 1]) == 1)
{
arrayList_map[i * 30 + j] = Convert.ToInt32(arrayList[i * 30 + j]) + 1;
}
}
//
if (((i + 1) * 30 + j - 1) >= 0 && ((i + 1) * 30 + j - 1) < 900 && j != 29) //
{
if (Convert.ToInt32(arrayList[(i + 1) * 30 + j - 1]) == 1)
{
arrayList_map[i * 30 + j] = Convert.ToInt32(arrayList[i * 30 + j]) + 1;
}
}
//
if (((i - 1) * 30 + j + 1) >= 0 && ((i - 1) * 30 + j + 1) < 900 && j != 0) //
{
if (Convert.ToInt32(arrayList[(i - 1) * 30 + j + 1]) == 1)
{
arrayList_map[i * 30 + j] = Convert.ToInt32(arrayList[i * 30 + j]) + 1;
}
}
//
if (((i + 1) * 30 + j + 1) >= 0 && ((i + 1) * 30 + j + 1) < 900 && j != 29) //
{
if (Convert.ToInt32(arrayList[(i + 1) * 30 + j + 1]) == 1)
{
arrayList_map[i * 30 + j] = Convert.ToInt32(arrayList[i * 30 + j]) + 1;
}
}
}
}
for (int i = 0; i < 30; i++)
{
for (int j = 0; j < 30; ++j)
{
Console.Write(arrayList_map[i * 30 + j]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.Read();
}
}
}
3実現効果以上が本文の全部です。皆さんの勉強に役に立つように、私たちを応援してください。