diff --git "a/\345\274\240\345\256\217/Program.cs" "b/\345\274\240\345\256\217/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b232cf7d2466a2a9d465f769d682c3bd750c64f7 --- /dev/null +++ "b/\345\274\240\345\256\217/Program.cs" @@ -0,0 +1,51 @@ +using System; + +namespace Demo1 +{ + class Program + { + public struct PersonStruct + { + public string name; + public string plone; + public string home; + + public PersonStruct(string name, string plone, string home) + { + this.name = name; + this.plone = plone; + this.home = home; + } + } + + + static void Main(string[] args) + { + //定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + + + + PersonStruct p1; + p1.name = "邓夏晖"; + p1.plone = "18379777344"; + p1.home = "上犹县"; + + PersonStruct p2; + p2.name = "张宏"; + p2.plone = "18460360774"; + p2.home = "南康区"; + + + p2.name ="张伟"; + p2.plone = p1.plone; + p2.home = p1.home; + + Console.WriteLine(p2.name); + Console.WriteLine(p2.plone); + Console.WriteLine(p2.home); + + } + } +} diff --git "a/\345\274\240\345\256\217/Program1.cs" "b/\345\274\240\345\256\217/Program1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c5c2e4a11de327f18be4e2670afce15bcfe37bd6 --- /dev/null +++ "b/\345\274\240\345\256\217/Program1.cs" @@ -0,0 +1,243 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo9 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine( ); + Console.WriteLine("---------------------------------------欢迎进入游戏世界--------------------------------"); + Console.WriteLine(); + Console.WriteLine("***************************************************************************************"); + Console.WriteLine("*************************************猜拳,开始****************************************"); + Console.WriteLine("***************************************************************************************"); + Console.WriteLine(); + + Console.WriteLine("出拳规则: 1,剪刀 2,石头 3,布"); + Console.WriteLine(); + + Text(); + + Console.WriteLine(); + Console.WriteLine("要继续吗? (Y / N)"); + char num5 = char.Parse(Console.ReadLine()); + if (num5 == 'Y') + { + Text(); + } + else + { + Console.WriteLine("游戏已退出!!!!!"); + } + + } + static void Text() + { + + Console.WriteLine("请选择对方的角色:<1:刘备 2:孙权 3:曹操>"); + int num = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入您的姓名:"); + string name = Console.ReadLine(); + Console.WriteLine(); + + if (num == 1) + { + Console.WriteLine(name + " VS " + " 刘备 对战!"); + } + else if (num == 2) + { + Console.WriteLine(name + " VS " + " 孙权 对战!"); + } + else + { + Console.WriteLine(name + " VS " + " 曹操 对战!"); + } + + Console.WriteLine("已选择好角色,确定开始游戏吗?(Y / N)"); + char num1 = char.Parse(Console.ReadLine()); + Console.WriteLine(); + + if (num1 == 'Y') + { + for (int i = 0; i < 3; i++) + { + Console.WriteLine(); + Console.WriteLine("请出拳: 1,剪刀 2,石头 3,布 (请输入相应数字!)"); + int num2 = int.Parse(Console.ReadLine()); + Console.WriteLine(); + + int num3 = 0; + int num4 = 0; + + if (num == 1) + { + if (num2 == 1 ) + { + Console.WriteLine(name + " 出拳:" + "剪刀"); + Console.WriteLine("刘备" + "出拳:" + "石头"); + Console.WriteLine("笨蛋," + name + "输了!"); + num4++; + } + else if(num2 == 2) + { + Console.WriteLine(name + " 出拳:" + "石头"); + Console.WriteLine("刘备"+ "出拳:" + "石头"); + Console.WriteLine("平局"); + + } + else + { + Console.WriteLine(name + " 出拳:" + "布"); + Console.WriteLine("刘备" + "出拳:" + "石头"); + Console.WriteLine("哈哈哈,你赢了"); + num3++; + } + + + } + else if (num == 2) + { + if (num2 == 1) + { + Console.WriteLine(name + " 出拳:" + "剪刀"); + Console.WriteLine("孙权" + "出拳:" + "石头"); + Console.WriteLine("真衰,嘿嘿,等着瞧!"); + num4++; + } + if (num2 == 2) + { + Console.WriteLine(name + " 出拳:" + "石头"); + Console.WriteLine("孙权" + "出拳:" + "石头"); + Console.WriteLine("平局"); + } + else + { + Console.WriteLine(name + " 出拳:" + "布"); + Console.WriteLine("孙权" + "出拳:" + "石头"); + Console.WriteLine("哈哈哈,你赢了"); + num3++; + } + + + } + else + { + if (num2 == 1) + { + Console.WriteLine(name + " 出拳:" + "剪刀"); + Console.WriteLine("曹操" + "出拳:" + "石头"); + Console.WriteLine("哈哈哈,真衰,你输了"); + num4++; + } + if (num2 == 2) + { + Console.WriteLine(name + " 出拳:" + "石头"); + Console.WriteLine("曹操" + "出拳:" + "石头"); + Console.WriteLine("平局"); + + } + else + { + Console.WriteLine(name + " 出拳:" + "布"); + Console.WriteLine("曹操" + "出拳:" + "石头"); + Console.WriteLine("哈哈哈,你赢了!"); + num3++; + } + + } + if (i == 2) + { + if (num == 1) + { + Console.WriteLine(); + Console.WriteLine("******************************"); + Console.WriteLine(); + Console.WriteLine(name + "VS" + "刘备"); + Console.WriteLine("对战次数:3"); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("刘备"+ " " + num4); + Console.WriteLine(name + " " + num3); + if (num3 > num4) + { + Console.WriteLine("恭喜" + name + "赢了!"); + } + else if(num3 < num4) + { + Console.WriteLine("恭喜" + "刘备"+ "赢了!"); + } + else + { + Console.WriteLine("哈哈哈,没想到吧,平局,嘿嘿!"); + } + + } + else if(num == 2) + { + Console.WriteLine(); + Console.WriteLine("******************************"); + Console.WriteLine(); + Console.WriteLine(name + "VS" + "孙权"); + Console.WriteLine("对战次数:3"); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("孙权" + " " + num4); + Console.WriteLine(name+ " " + num3); + if (num3 > num4) + { + Console.WriteLine("恭喜" + name + "赢了!"); + } + else if(num3 < num4) + { + Console.WriteLine("恭喜" + "孙权" + "赢了!"); + } + else + { + Console.WriteLine("哈哈哈,没有想到吧,平局,嘿嘿."); + } + + } + else + { + Console.WriteLine(); + Console.WriteLine("******************************"); + Console.WriteLine(); + Console.WriteLine(name + "VS" + "曹操"); + Console.WriteLine("对战次数:3"); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("曹操"+ " " + num4); + Console.WriteLine(name + " " + num3); + if (num3 > num4) + { + Console.WriteLine("恭喜" + name + "赢了!"); + } + else if (num3 < num4) + { + Console.WriteLine("恭喜" + "曹操" + "赢了!"); + } + else + { + Console.WriteLine("哈哈哈,没有想到吧,平局,嘿嘿."); + } + + + } + + } + } + + } + else + { + Console.WriteLine("系统退出!!!"); + } + + } + } +}