20150313

练习:

一、石头、剪刀、布,编辑程序

//int a=r.Next(0,3); //int b=r.Next(0,3);

//switch (a) //{ // case 0://剪刀 // x = "剪刀"; // break; // case 1://石头 // x = "石头"; // break; // case 2://布 // x = "布"; // break; // default: // x = "耍赖"; // break; //} //switch (b) //{ // case 0://剪刀 // y = "剪刀"; // break; // case 1://石头 // y = "石头"; // break; // case 2://布 // y = "布"; // break; // default: // y = "耍赖"; // break; //}
//Console.WriteLine("x出的是"+x); //Console.WriteLine("y出的是" + y); //string jg = ""; //if (a==b) //{ // jg = "平局"; //} //else if (a>b) //{ // if (a==2&&b==0) // { // jg = "Y胜利"; // } // else // { // jg = "X胜利!"; // }
//} //else if (b>a) //{ // if ((b==2&&a==0)) // { // jg = "X胜利!"; // } // else // { // jg = "Y胜利!"; // }
//} //if (a==b) //{ // jg = "平局"; //} //else if (a>b||(b==2&&a==0)) //{ // jg = "a胜利"; //} //else if (b>a||(a==2&&b==0)) //{ // jg = "b胜利"; //}

二、俩人对战游戏编程

//        static void Main(string[] args) //        { //            wanjia wj1 = new wanjia(); //            wanjia wj2 = new wanjia(); //            Random r=new Random(); //            //载入姓名 //            Console.WriteLine("请输入第一个玩家昵称:"); //            wj1.nc = Console.ReadLine(); //            Console.WriteLine("请输入第二个玩家昵称:"); //            wj2.nc = Console.ReadLine(); //            while (true) //            { //            //载入血量 //            wj1.mp = 1000 + r.Next(0,1000); //            wj2.mp = 1000 + r.Next(0,1000); //            //载入法力 //            wj1.hp = 1000 + r.Next(0,1000); //            wj2.hp = 1000 + r.Next(0,1000); //            //载入攻击力 //            wj1.gongji = 50+ r.Next(0,100); //            wj2.gongji = 50 + r.Next(0,100); //            //载入防御力 //            wj1.fangyu = 50 + r.Next(0,100); //            wj2.fangyu = 50 + r.Next(0,100); //            //载入技能             //            wj1.jineng =new string [6]{"普通攻击","辟邪剑","寒光剑","清风剑","雷霆剑诀","无名剑诀"}; //            wj2.jineng =new string [6]{"普通攻击","葵花宝典","吸星大法","无法无天","大海无量","损人不利己"};            //            Console.WriteLine("昵称:" + wj1.nc + "\t生命:" + wj1.mp + "\t法力:" + wj1.hp + "\t攻击:" + wj1.gongji + "\t防御:" + wj1.fangyu); //            Console.WriteLine("VS"); //            Console.WriteLine("昵称:" + wj2.nc + "\t生命:" + wj2.mp + "\t法力:" + wj2.hp + "\t攻击:" + wj2.gongji + "\t防御:" + wj2.fangyu);

//            Console.WriteLine("是否开始对阵(Y/N)?"); //            string s = Console.ReadLine();           //            if (s.ToUpper()=="N") //            { //                break; //            } //            else //            { //                //对战 //                while (true) //                { //                     int chushou = r.Next(0,3); //                if (chushou==0)//wj1对wj2出手 //                {                     //                    //掉血掉蓝计算函数                     //                    int dx = 0, dl = 0; //                    int ss = r.Next(0,6); //                    switch (ss) //                    { //                        case 0: //                            dx = r.Next(0, 20); //                            dl = r.Next(5, 15); //                            break; //                        case 1: //                            dx = r.Next(20, 40); //                            dl = r.Next(10, 20); //                            break; //                        case 2: //                            dx = r.Next(40, 80); //                            dl = r.Next(20, 40); //                            break; //                        case 3: //                            dx = r.Next(80, 120); //                            dl = r.Next(40, 80); //                            break; //                        case 4: //                            dx = r.Next(120, 200); //                            dl = r.Next(60, 100); //                            break; //                        case 5: //                            dx = r.Next(200, 500); //                            dl = r.Next(100, 200); //                            break;

//                        default: //                            break; //                    }                     //                    dx = wj1.gongji + dx - wj2.fangyu;                     //                    wj2.mp -= dx; //                    wj1.hp -= dl; //                    if (wj2.mp<=0) //                    { //                        wj2.mp = 0;

//                    } //                    if (wj1.hp <= 0) //                    { //                        wj1.hp = 0;

//                    }                     //                    if (dx<0) //                    { //                        dx = 0; //                    } //                    if (dx == 0) //                    { //                        Console.WriteLine(wj2.nc+"成功躲过了"+wj1.nc+"的攻击"); //                    }                     //                    if (wj1.hp <= 0) //                    { //                        Console.WriteLine(wj1.nc + "没蓝了!!"); //                        chushou = 1; //                    } //                   Console.WriteLine(wj1.nc + "消耗" + dl + "点法力使出了" + wj1.jineng[ss] + ",\t" + wj2.nc + "掉血" + dx + "滴");                    //                    if (wj1.mp <= 0 && wj2.mp <= 0) //                    { //                        Console.WriteLine(wj1.nc + "与" + wj2.nc + "双双赴死了!!"); //                        break; //                    } //                    if (wj2.mp <= 0) //                    { //                        Console.WriteLine(wj1.nc + "把" + wj2.nc + "蹂躏死了!!"); //                        break; //                    } //                    Console.WriteLine("\n"); //                    Console.WriteLine("昵称:" + wj1.nc + "\t生命:" + wj1.mp + "\t法力:" + wj1.hp);

//                    Console.WriteLine("昵称:" + wj2.nc + "\t生命:" + wj2.mp + "\t法力:" + wj2.hp); //                    Console.WriteLine("\n");

//                } //                   System.Threading.Thread.Sleep(1000); //                if (chushou==1)//wj2对wj1出手 //                {                     //                    //掉血掉蓝计算函数 //                    int dx = 0, dl = 0; //                    int ss = r.Next(0,6); //                    switch (ss) //                    { //                        case 0: //                            dx = r.Next(0, 20); //                            dl = r.Next(5, 15); //                            break; //                        case 1: //                            dx = r.Next(20, 40); //                            dl = r.Next(10, 20); //                            break; //                        case 2: //                            dx = r.Next(40, 80); //                            dl = r.Next(20, 40); //                            break; //                        case 3: //                            dx = r.Next(80, 120); //                            dl = r.Next(40, 80); //                            break; //                        case 4: //                            dx = r.Next(120, 200); //                            dl = r.Next(60, 100); //                            break; //                        case 5: //                            dx = r.Next(200, 500); //                            dl = r.Next(100, 200); //                            break;

//                        default: //                            break; //                    } //                    dx = wj2.gongji + dx - wj1.fangyu; //                    wj1.mp -= dx; //                    wj2.hp -= dl; //                    if (dx < 0) //                    { //                        dx = 0; //                    } //                    if (dx == 0) //                    { //                        Console.WriteLine(wj2.nc + "成功躲过了" + wj1.nc + "的攻击"); //                    } //                    if (wj1.mp <= 0) //                    { //                        wj1.mp = 0;

//                    } //                    if (wj2.hp <= 0) //                    { //                        wj2.hp = 0;

//                    } //                    if (wj1.hp <= 0) //                    { //                        Console.WriteLine(wj1.nc + "没蓝了!!"); //                        chushou = 0; //                    } //                     Console.WriteLine(wj2.nc + "消耗" + dl + "点法力使出了" + wj2.jineng[ss] + ",\t" + wj1.nc + "掉血" + dx + "滴"); //                    if (wj1.mp <= 0 && wj2.mp <= 0) //                    { //                        Console.WriteLine(wj1.nc + "与" + wj2.nc + "双双赴死了!!"); //                        break; //                    } //                    if (wj2.mp <= 0) //                    { //                        Console.WriteLine(wj1.nc + "把" + wj2.nc + "蹂躏死了!!"); //                        break; //                    }

//                    Console.WriteLine("\n"); //                    Console.WriteLine("昵称:" + wj1.nc + "\t生命:" + wj1.mp + "\t法力:" + wj1.hp); //                    Console.WriteLine("昵称:" + wj2.nc + "\t生命:" + wj2.mp + "\t法力:" + wj2.hp); //                    Console.WriteLine("\n"); //                } //                else //                { //                    Console.WriteLine("双方都在等待对方露出破绽....."); //                } //                }

//            } //            Console.WriteLine("再来一局"); //            Console.ReadKey(); //            } //            Console.WriteLine("退出对战。。。。");

三、推箱子编程

static void Main(string[] args) ////        { ////            int x = 1, y = 1;//初始人的坐标 ////            int[,] tu = new int[10, 10]//定义原始地图 ////            { ////            {1,1,1,1,1,1,1,1,1,1}, ////            {1,4,0,0,0,0,0,0,0,1}, ////            {1,0,0,0,1,1,1,1,0,1}, ////            {1,0,0,0,1,5,0,1,0,1}, ////            {1,1,1,1,1,1,0,1,0,1}, ////            {1,1,0,0,0,0,0,1,0,1}, ////            {1,1,0,1,1,1,1,1,0,1}, ////            {1,1,0,0,0,0,0,0,0,1}, ////            {1,1,1,0,0,0,0,0,0,1}, ////            {1,1,1,1,1,1,1,1,1,1} ////            };//一张地图 ////            ditus(tu);//调用地图显示 ////            while (true) ////            { ////                int temp = 0;//临时变量 ////                ConsoleKeyInfo s = Console.ReadKey();//用s接收按键类型 ////                if (s.Key.ToString() == "UpArrow")//如果按键上键 ////                { ////                    if (tu[x - 1, y] == 0 || tu[x - 1, y] == 5)//如果上面是0或者5 ////                    { ////                        //交换位置 ////                        temp = tu[x - 1, y]; ////                        tu[x - 1, y] = tu[x, y]; ////                        tu[x, y] = temp; ////                        x--;//人的坐标上移一位 ////                    } ////                } ////                else if (s.Key.ToString() == "DownArrow")//如果按键下键 ////                { ////                    if (tu[x + 1, y] == 0 || tu[x + 1, y] == 5)//如果下面是0或者5 ////                    { ////                       // 交换位置 ////                        temp = tu[x + 1, y]; ////                        tu[x + 1, y] = tu[x, y]; ////                        tu[x, y] = temp; ////                        x++;//人的坐标下移一位 ////                    } ////                } ////                else if (s.Key.ToString() == "LeftArrow")//如果按键左键 ////                { ////                    if (tu[x, y - 1] == 0 || tu[x, y - 1] == 5)//如果左面是0或者5 ////                    { ////                        //交换位置 ////                        temp = tu[x, y - 1]; ////                        tu[x, y - 1] = tu[x, y]; ////                        tu[x, y] = temp; ////                        y--;//人的坐标左移一位 ////                    } ////                } ////                else if (s.Key.ToString() == "RightArrow")//如果按键右键 ////                { ////                    if (tu[x, y + 1] == 0 || tu[x, y + 1] == 5)//如果右面是0或者5 ////                    { ////                       // 交换位置 ////                        temp = tu[x, y + 1]; ////                        tu[x, y + 1] = tu[x, y]; ////                        tu[x, y] = temp; ////                        y++;//人的坐标右移一位 ////                    } ////                } ////                else ////                {

////                } ////                if (temp == 5)//如果移动后位置上是5 ////                { ////                    Console.WriteLine("成功走出迷宫!");//提示走出迷宫 ////                }

////                Console.Clear();//清屏 ////                ditus(tu);//显示地图 ////            } ////            Console.ReadLine(); ////        }

////        public static void ditus(int[,] tu)//创建ditus函数 ////        { ////            string[,] ditu = new string[10, 11];//定义string类型地图 ////            for (int i = 0; i < 10; i++) ////            { ////                for (int j = 0; j < 10; j++) ////                { ////                    if (tu[i, j] == 0) ////                    { ////                        ditu[i, j] = "  "; ////                    } ////                    if (tu[i, j] == 1) ////                    { ////                        ditu[i, j] = "■"; ////                    } ////                    if (tu[i, j] == 2) ////                    { ////                        ditu[i, j] = "●"; ////                    } ////                    if (tu[i, j] == 3) ////                    { ////                        ditu[i, j] = "◎"; ////                    } ////                    if (tu[i, j] == 4) ////                    { ////                        ditu[i, j] = "人"; ////                    } ////                    if (tu[i, j] == 5) ////                    { ////                        ditu[i, j] = "※"; ////                    } ////                    if (tu[i, j] == 7) ////                    { ////                        ditu[i, j] = "人"; ////                    } ////                } ////                ditu[i, 10] = "\n";//换行 ////            } ////            foreach (string s in ditu)//打印地图 ////            { ////                Console.Write(s); ////            } ////        }

////    } ////}

四、计算机

static public double jaq(double x, double y, string m)         {

double z;             m = (m == "加" || m == "+") ? "加" : (m == "减" || m == "-") ? "减" : (m == "乘" || m == "*" || m == "×") ? "乘" : (m == "除" || m == "/" || m == "÷") ? "除" : "加";             Console.WriteLine("进行的是" + m + "法运算");             switch (m)             {                 case "加":

z = x + y;                     break;                 case "减":

z = x - y;                     break;                 case "乘":

z = x * y;                     break;                 case "除":

z = x / y;                     break;                 default:

z = x + y;                     break;             }             return z;         }

static void Main(string[] args)         {

Console.Title = "加减乘除";

double x, y, z = 0;             string m;             while (true)             {                 Console.WriteLine("第一个数:");                 x = Convert.ToDouble(Console.ReadLine());                 Console.WriteLine("运算符(默认为加):");                 m = Console.ReadLine();

Console.WriteLine("第二个数:");                 y = Convert.ToDouble(Console.ReadLine());

z = jaq(x, y, m);

Console.WriteLine("运算结果是" + z);                 ConsoleKeyInfo s;                 Console.TreatControlCAsInput = true;                 Console.WriteLine("按任意键从新开始(Esc退出)\n");                 s = Console.ReadKey();

if (s.Key == ConsoleKey.Escape)                 {                     break;                 }

}             Console.WriteLine("结束!!");             Console.ReadKey();

}

} }

时间: 2024-10-25 14:27:35

20150313的相关文章

20150313 驱动模块分离概念

20150313 驱动模块分离概念 2015-03-13 Lover雪儿 还记得以前刚开始学习编写程序的时候,无论再多的代码,再多的功能都是使劲的往同一个.C文件中塞,最后导致的直接结果就是,代码多,功能复杂,严重的妨碍了我们代码可移植性甚至良好的阅读性,接下来,我们开始来学习将一个驱动程序进行拆分,根据各种代码的性质或者功能来写入不同的.C文件中,此处,我们来尝试使用平台设备来实现IMX257蜂鸣器的驱动分离代码. 前面我们实现了beep驱动,博客地址http://www.cnblogs.co

20150313+微信-全

价值万元的微信教程下 目录 价值万元的微信教程下 1 一.响应式设计 2 1.未来网页的发展趋势 2 2.早期的解决方案 2 3.解决之道 2 4.自适应网页设计 3 二.响应式案例 5 1.思路 5 2.响应式设计核心代码 5 1)让我们的网页去适应屏幕 5 2)改变网页的宽度 6 3)媒体查询 6 4)让多媒体标签去适应屏幕 6 5)让文字去适应屏幕 7 一.响应式设计 1.未来网页的发展趋势 随着3G.4G的普及,越来越多的人使用手机上网. 移动设备正超过桌面设备,成为访问互联网的最常见终

2015-03-13 ls,cd,alias,PATH,目录结构,快捷键

内容概要: 1. 命令ls -l   详细信息 -a  查看隐藏的文件或目录 -d   只看目录本身,不列出目录下面的文件和目录 -t 以时间先后排序 2  目录结构  (参考http://yangrong.blog.51cto.com/6945369/1288072) /bin, /sbin, /usr/bin, /usr/sbin  放命令的目录,sbin是超级用户root才可以用的命令 /boot Linux内核及引导系统程序所需要的文件目录 /dev 存放的是Linux的外部设备 /et

怎样写APP计划书-20150313早读课

我们每天都会收到拥有APP创意的人们的电话和邮件,他们想知道把这样的APP做出来需要多少钱.在Calvium,我们尽可能帮助他们,但有时候 做这样的报价真的很难.询问一款APP的价值,就和询问一条绳子的长度一样(译者注:意思是不知道明确的范围).因此,尽可能多地阐明你的想法尤为重要, 并且最好拥有一份产品计划书来说明你的想法. 许多人只有他们创意的基本思路,却想先把这些告诉给工程师,利用他们在行业领域的专业知识来充实他们的想法.这很好!许多代理公司都提供日结算服务或者是咨询服务,如果你还不自信,

HDU 2897-邂逅明下(sg函数)

邂逅明下 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 2897 Appoint description:  System Crawler  (2015-03-13) Description 当日遇到月,于是有了明.当我遇到了你,便成了侣. 那天,日月相会,我见到了你.而且,大地失去了光辉,你我是否成侣?这注定是个凄美的故事.(以上是废

重新安装Ubuntu12.04

重新安装Ubuntu12.04 之所以我重新安装Ubuntu,因为我第一次给根目录分配的空间过小,好像是20GB吧~结果编译Android的时候,编译了3个小时候直接中止掉了.郁闷.这个也告诉我们一定概要根据自己的需求去进行分区的大小分配.因此这次给根目录分配大点空间.当然这是利用DiskGenius实现的. 所用文件下载链接: mbrfix.exe: http://linux.linuxidc.com/pub/2007/Windows%E4%B8%8B%E4%BF%AE%E5%A4%8Dmbr

微信模板消息测试

模板消息定义 目前允许发的模板消息示例   1.1资料变更类通知示例如下: 标题 内容 示例 会员卡申请资料变更通知 {{first.DATA}} 会员卡号:{{keyword1.DATA}} 会员姓名:{{keyword2.DATA}} 变更内容:{{keyword3.DATA}} 时间:{{keyword4.DATA}} {{remark.DATA}} 尊敬的会员,您的资料变更成功 会员卡号:0000 0000 会员姓名:李XX 变更内容:1234567890 时间:2015年5月5日 感谢

python使用httplib2访问REST服务的例子

首先你需要安装httplib2,这个可以在github上找到: 然后你需要获得一个http连接的对象: con = httplib2.Http()   然后你需要发起连接: (6)resp, (5)content = con.request( (1)BAIDU_COM_API_COMMENTS, (2)method="POST", body=(3)body,headers=(4)header_data)参数1是访问的URL:比如sina.com 参数2是method:get,post,

drbd 配置

DRBD(Distributed Replicated Block Device),DRBD 号称是 "网络 RAID",开源软件,由 LINBIT 公司开发.DRBD实际上是一种块设备的实现,主要被用于Linux平台下的高可用(HA)方案之中.他有内核模块和相关程序而组成,通过网络通信来同步镜像整个设备,有点类似于一个网络RAID-1的功能.也就是说当你将数据写入本地的DRBD设备上的文件系统时,数据会同时被发送到网络中的另外一台主机之上,并以完全相同的形式记录在文件系统中.本地节点