网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
07月27日漏签0天
c#吧 关注:188,471贴子:822,946
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 16回复贴,共1页
<<返回c#吧
>0< 加载中...

大家帮帮忙 这是我的作业啊 帮我改改错误吧

  • 只看楼主
  • 收藏

  • 回复
  • 球球_不会滚
  • c#爱好者
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
求求大家


  • 球球_不会滚
  • c#爱好者
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
using System;
public class Game
{
public static void Main(string[] args)
{
int selection;
Console.WriteLine("Please select Games:1.Guessing game;2.Finger guessing game;3.Flight chess;");
selection = Convert.ToInt32(Console.ReadLine());
switch (selection)
{
case 1:
Console.WriteLine("欢迎进入猜数字游戏!游戏规则:随机产生一个1~100之间的一个数,并由玩家进行猜测。\r\n提示玩家是猜大了还是猜小了或是猜对了。\n Good lucky yo tou!");
while (true)
{
Random rd = new Random();
int result = rd.Next(0, 100);
Console.WriteLine("请请输入一个整数(范围为1~100)");
while (true)
{
int input = int.Parse(Console.ReadLine());
if (input == result)
{
Console.WriteLine("恭喜你,猜对了!");
break;
}
else if (input < result)
Console.WriteLine("猜小了!");
else
Console.WriteLine("猜大了!");
}
Console.WriteLine("是否继续,是请输入Y,否请输入N:");
char C = char.Parse(Console.ReadLine());
if (C == 'N')
break;
}
break;
case 2:
Console.WriteLine("欢迎进入简单的猜拳游戏~这个游戏就是简单地石头剪刀布噢,相信大家都有玩过,祝你玩得开心哟");
Console.WriteLine("1代表石头,2代表剪子,3代表布哦");
int stone1 = 1; //代表石头
int scissors1 = 2; // 代表剪子
int cloth1 = 3; //代表布
System.Random rnd = new System.Random();
string aj = Console.ReadLine();
int nbr = (int)rnd.Next(1, 3); //随机数//
string rnd1 = Convert.ToString(nbr); //将rnd的int转化为string//
string stone = Convert.ToString(stone1); //同上//
string scissors = Convert.ToString(scissors1); //同上//
string cloth = Convert.ToString(cloth1);
if ((rnd1 == stone) && (aj == cloth) || (rnd1 == scissors) && (aj == stone) || (rnd1 == cloth) && (aj == scissors))
{
Console.WriteLine("恭喜你!你胜利了!");
}
if ((rnd1 == stone) && (aj == scissors) || (rnd1 == scissors) && (aj == cloth) || (rnd1 == cloth) && (aj == stone))
{
Console.WriteLine("很遗憾!我出局了!");
}
if ((rnd1 == stone) && (aj == stone) || (rnd1 == scissors) && (aj == scissors) || (rnd1 == cloth) && (aj == cloth))
{
Console.WriteLine("再加油噢!是平手!");
}
break;
case 3:
//在数组中 1:幸运轮盘◎
// 2:地雷☆
// 3:暂停▲
// 4:时空隧道卍
// -1:普通棋格□
static int[] mapi = new int[100];
static string[] playername = new string[2];
static int[] playeri = new int[2];
static void Main(string[] args)
{
playeri[0] = 0;
playeri[1] = 0;
装饰();
名字();
Console.Clear();
装饰();
方块();
棋盘();
playGame();
Console.ReadKey(true);
}
private static void playGame()
{
while (true)
{
for (int i = 0; i < 2; i++)
{
Dice(i);
if (playeri[i] >= 99)
{
Console.WriteLine();
Console.WriteLine("{0}获得胜利,按任意键退出游戏", playername[i]);
return;
}
}
}
}
private static void 名字()
{
Console.WriteLine("请输入玩家1的名字");
playername[0] = Console.ReadLine();
while (playername[0] == "")
{
Console.WriteLine("名字不能为空,请重新输入");
playername[0] = Console.ReadLine();
}
Console.WriteLine("请输入玩家2的名字");
playername[1] = Console.ReadLine();
while (playername[1] == "" || playername[1] == playername[0])
{
if (playername[1] == "")
{
Console.WriteLine("名字不能为空,请重新输入");
}
else
{
Console.WriteLine("名字不能相同,请重新输入");
}
playername[1] = Console.ReadLine();
}
}
private static void 装饰()
{
Console.WriteLine("*****************************************************************");
Console.WriteLine("* *");
Console.WriteLine("* 飞行棋 *");
Console.WriteLine("* *");
Console.WriteLine("*****************************************************************");
Console.WriteLine(" 幸运轮盘◎ 地雷☆ 暂停▲ 时空隧道卍");


2025-07-27 18:26:39
广告
不感兴趣
开通SVIP免广告
  • 球球_不会滚
  • c#爱好者
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
}
private static void 方块()
{
for (int i = 0; i < mapi.Length; i++)
{
mapi[i] = -1;
}
int[] luckTurn = { 6, 23, 40, 55, 69, 83 };
int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };
int[] pause = { 9, 27, 60, 93 };
int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };
for (int i = 0; i < 6; i++)
{
mapi[luckTurn[i]] = 1;
}
for (int i = 0; i < 9; i++)
{
mapi[landMine[i]] = 2;
}
for (int i = 0; i < 4; i++)
{
mapi[pause[i]] = 3;
}
for (int i = 0; i < 7; i++)
{
mapi[timeTunnel[i]] = 4;
}
}
private static void 棋盘()
{
for (int i = 0; i < 30; i++)
{
Console.Write(Getmapi(mapi[i], i));
}
Console.WriteLine();
for (int i = 30; i < 35; i++)
{
for (int q = 0; q < 29; q++)
{
Console.Write(" ");
}
Console.Write(Getmapi(mapi[i], i));
Console.WriteLine();
}
for (int i = 64; i >= 35; i--)
{
Console.Write(Getmapi(mapi[i], i));
}
Console.WriteLine();
for (int i = 65; i < 70; i++)
{
Console.Write(Getmapi(mapi[i], i));
for (int q = 0; q < 29; q++)
{
Console.Write(" ");
}
Console.WriteLine();
}
for (int i = 70; i < 100; i++)
{
Console.Write(Getmapi(mapi[i], i));
}
}
public static string Getmapi(int x, int i)
{
string zifu = "";
if (i == playeri[0])
{
zifu = "A";
Console.ForegroundColor = ConsoleColor.White;
}
else if (i == playeri[1])
{
zifu = "B";
Console.ForegroundColor = ConsoleColor.White;
}
else
{
switch (x)
{
case -1:
zifu = "□";
Console.ForegroundColor = ConsoleColor.White;
break;
case 1:
zifu = "◎";
Console.ForegroundColor = ConsoleColor.Red;
break;
case 2:
zifu = "☆";
Console.ForegroundColor = ConsoleColor.Yellow;
break;
case 3:
zifu = "▲";
Console.ForegroundColor = ConsoleColor.DarkYellow;
break;
case 4:
zifu = "卍";
Console.ForegroundColor = ConsoleColor.Blue;
break;
default:
zifu = "□";
Console.ForegroundColor = ConsoleColor.White;
break;
}
}
return zifu;
}
public static void Dice(int income)
{
int point = 0;
Console.WriteLine();
Console.WriteLine("请{0}按下任意键投掷骰子", playername[income]);
Console.ReadKey(true);
Random r = new Random();
point = r.Next(1, 7); //随机数;
Console.WriteLine("{0}掷出了{1}点。", playername[income], point);
Console.WriteLine("请按任意键继续...");
Console.ReadKey(true);
playeri[income] += point;
if (playeri[0] == playeri[1])
{
Console.WriteLine("{0}飞的太慢了,被撞毁了", playername[1 - income]);
playeri[1 - income] = 0;
Console.ReadKey(true);
}
Console.Clear();
装饰();
棋盘();
trap(income);
Console.Clear();
装饰();
棋盘();
}
public static void trap(int income)
{
if (mapi[playeri[income]] == 3)
{
Console.WriteLine();
Console.WriteLine("人品不好,{0}暂停一回合。", playername[income]);
Console.ReadKey(true);
Dice(1 - income);
}
if (mapi[playeri[income]] == 2)
{
Console.WriteLine();
Console.WriteLine("{0}不幸踩到地雷了,倒退6格", playername[income]);
Console.ReadKey(true);
playeri[income] -= 6;
if (playeri[income] < 0)
playeri[income] = 0;
Console.Clear();
棋盘();
trap(income);
}
if (mapi[playeri[income]] == 4)
{
Console.WriteLine();
Console.WriteLine("{0}进入时空隧道随机前进1-10格", playername[income]);
Console.ReadKey(true);
Random r2 = new Random();
int point = r2.Next(1, 7);
Console.WriteLine("前进了{0}格!", point);
playeri[income] += point;
Console.ReadKey();
Console.Clear();
棋盘();
trap(income);
}
if (mapi[playeri[income]] == 1)
{
Console.WriteLine();
Console.WriteLine("人品不错,因为我忘记要做什么,所以随机其他三个");
Console.ReadKey(true);
Random a = new Random();
int p = a.Next(1, 4);
if (p == 1)
{
Console.WriteLine();
Console.WriteLine("人品不好,{0}暂停一回合。", playername[income]);
Console.ReadKey(true);
Dice(1 - income);
}
else if (p == 2)
{
Console.WriteLine();
Console.WriteLine("{0}不幸踩到地雷了,倒退6格", playername[income]);
Console.ReadKey(true);
playeri[income] -= 6;
if (playeri[income] < 0)
playeri[income] = 0;
Console.Clear();
棋盘();
trap(income);
}
else
{
Console.WriteLine();
Console.WriteLine("{0}进入时空隧道随机前进1-10格", playername[income]);
Console.ReadKey(true);
Random r2 = new Random();
int point = r2.Next(1, 7);
Console.WriteLine("前进了{0}格!", point);
playeri[income] += point;
Console.ReadKey();
Console.Clear();
棋盘();
trap(income);
}
break;
}
}
}
}


  • 球球_不会滚
  • c#爱好者
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
由于太长 所以分了两次发。。。有以下几个错误。。


  • 球球_不会滚
  • c#爱好者
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼


  • 爱电脑疯子
  • c#探索者
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
和java高度相似


  • 球球_不会滚
  • c#爱好者
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
这个程序是 想让别人选不同的游戏 用switch来实现
这个飞行棋的程序我是从网上下载来的,所以有主函数开头
那怎样才能弄到switch里面呢?求解


  • 153828050
  • c#爱好者
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
用线程


2025-07-27 18:20:39
广告
不感兴趣
开通SVIP免广告
  • 153828050
  • c#爱好者
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
或者两个游戏分成两个库类
选哪个就进那个


  • 清浅
  • c#砖家
    13
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
完全搞不懂~


  • 死作作死
  • c#大菜鸟
    4
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
mark


  • 一株青草儿
  • c#牛人
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
加我 346 414 491


  • Mondo_S
  • c#码农
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
上面 public class 里面 的main 换掉;
上面一个main 下面一个main


  • 轻吟伱给的忧伤
  • c#码农
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
直接把提示错误的代码贴出来就好了,搞这么长,都懒得看


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 16回复贴,共1页
<<返回c#吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示