zoukankan      html  css  js  c++  java
  • C#结构体

    class Program
        {
            struct student
            {
                public int code;
                public string name;
                public double score;
            }
    
            public int rz=0;
            public int dz = 0;
    
            public string bj(int a , int b)
            {
                int d = a - b;
                if (d==-2||d==1)
                {
                    return "";
                }
                else if (d==2||d==-1)
                {
                    return "电脑";
                }
                else
                {
                    return "";
                }
            }
    
    
            static void Main(string[] args)
            {
                //输入人的100以内的数
                //随机电脑100以内的数
                //若人的数大,给人加分
                //若电脑的大,给电脑加分
                //若相等,两个都加分
                //Random ran = new Random();
                //int dian = ran.Next(101);
                //Console.Write("请输入一个100以内的整数:");
                //int ren = int.Parse(Console.ReadLine());
    
                //Program hanshu = new Program();
                //string s = hanshu.daxiao(ren,dian);
    
                //switch (s)
                //{ 
                //    case "人":
                //        hanshu.renzong++;
                //        break;
                //    case "电脑":
                //        hanshu.dianzong++;
                //        break;
                //    case "和":
                //        hanshu.renzong++;
                //        hanshu.dianzong++;
                //        break;
                //}
                //Console.WriteLine("人的分数:{0},电脑的分数:{1}",hanshu.renzong,hanshu.dianzong);
    
                //Console.ReadLine();
    
    
    
    
                //创建一个存储学生学号、姓名、成绩的结构体
                //根据人数分别输入,然后放置在集合中,
                //所有数据录入完成之后,进行打印
                //ArrayList al = new ArrayList();
                //Console.Write("请输入学生人数:");
                //int a = int.Parse(Console.ReadLine());
                //for (int i = 0; i < a; i++)
                //{
                //    student code = new student();
                //    Console.Write("请输入学号:");
                //    code.code = int.Parse(Console.ReadLine());
                //    Console.Write("请输入姓名:");
                //    code.name = Console.ReadLine();
                //    Console.Write("请输入成绩:");
                //    code.score = double.Parse(Console.ReadLine());
                //    al.Add(code);
                //}
                //Console.WriteLine("输入完毕,您输入的正确");
                //Console.ReadLine();
                //for (int i = 0; i < a; i++)
                //{
                //    student code = (student)al[i];
    
                //    Console.WriteLine("学号" + code.code + "名字" + code.name + "成绩" + code.score);
                //}
                //Console.ReadLine();
    
    
                   
    
    
    
    
                //猜拳,5局3胜
                //要求使用公用变量
                Random sj = new Random();
                Program zdy=new Program();
                while (zdy.rz < 3 && zdy.dz < 3)
                {
                    Console.WriteLine("请输入剪刀石头布的数字编码(1为剪刀,2为石头,3为布):");
                    int a = int.Parse(Console.ReadLine());
                    int b = sj.Next(1,4);
                    string jg = zdy.bj(a, b);
                    switch (jg)
                    {
                        case "":
                            zdy.rz++;
                            Console.WriteLine("本局你获胜");
                            break;
                        case "电脑":
                            zdy.dz++;
                            Console.WriteLine("本局电脑获胜");
                            break;
                        case "":
                            Console.WriteLine("本局平局");
                            break;
                    }
                    
                }
                if (zdy.rz > zdy.dz)
                {
                    Console.WriteLine("你赢了");
                }
                else
                {
                    Console.WriteLine("你输了");
    
                }
                Console.ReadLine();
  • 相关阅读:
    oracle Blob处理
    开机启动
    获取本机IP
    MSSQL通用分页过程
    转:Delphi2010小写金额转大写金额的源代码
    HWND Handle HModule区别
    常见问题
    Oracle ORA-01033: 错误解决办法
    lvs- lvs(DR模式)+keepalived
    lb-常用的负载均衡软件
  • 原文地址:https://www.cnblogs.com/blueteasama/p/5655869.html
Copyright © 2011-2022 走看看