面向对象程序设计实验考试

2023-11-02

 1、圆的面积

namespace CircleArea
{
    class Program
    {
        static void Main(string[] args)
        {
            const double PI = 3.1415926;  
            double Radius,Area;
            Console.Write("请输入要计算面积的圆形的半径:");
            Radius = double.Parse(Console.ReadLine());
            //Area = PI * Radius * Radius;
            Area = PI * Math.Pow(Radius, 2);
            Console.WriteLine("半径为{0}的圆形面积为{1}",Radius,Area);
        }
    }
}

2、判断是否为正方形

namespace Struct
{
    class Program
    {
        struct Rectangle
        {
            public double Width;
            public double Height;

            public bool IsSquare()
            {
                return Width == Height;
            }
        };
        static void Main(string[] args)
        {
            Rectangle rect;
            string issquare;
            Console.WriteLine("请输入矩形的长:");
            rect.Height = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入矩形的宽:");
            rect.Width = double.Parse(Console.ReadLine());
            if (rect.IsSquare())
            {
                issquare = "是";
            }
            else 
            {
                issquare = "不是";
            }
            Console.WriteLine("长为{0},宽为{1}的矩形{2}正方形!", rect.Height, rect.Width, issquare);

        }
    }
}

3、switch

namespace OnSpecial
{
    class Program
    {
        enum Week
        {
            Sunday,
            Monday,
            Tuesday,
            Wenesday,
            Thursday,
            Friday,
            Saturday
        }
        static void Main(string[] args)
        {
            Console.WriteLine("请输入星期:");
            Week week = (Week)int.Parse(Console.ReadLine());
            switch(week)
            {
                case Week.Sunday:
                    Console.WriteLine("星期日特价菜:爆炒牛肉18元");
                    break;
                case Week.Monday:
                    Console.WriteLine("星期一特价菜:啤酒鸭26元");
                    break;
                case Week.Tuesday:
                    Console.WriteLine("星期二特价菜:红烧肉20元");
                    break;
                case Week.Wenesday:
                    Console.WriteLine("星期三特价菜:回锅肉16元");
                    break;
                case Week.Thursday:
                    Console.WriteLine("星期四特价菜:水煮鱼24元");
                    break;
                case Week.Friday:
                    Console.WriteLine("星期五特价菜:剁椒鱼头30元");
                    break;
                case Week.Saturday:
                    Console.WriteLine("星期六特价菜:手撕包菜12元");
                    break;
                default:
                    break;
            }
        }
    }
}

4、for循环嵌套调用

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CockHenChicknum
{
    class Program
    {
        static void Main(string[] args)
        {
            int cock, hen, chick;
            for (cock = 0; cock <= 20; cock++)
            {
                for (chick = 0; chick <= 99; chick += 3)
                {
                    hen = 100 - cock - chick;
                    if (hen >= 0 && hen <= 33 && cock * 5 + chick / 3 + hen * 3 == 100)
                    {
                        Console.WriteLine("公鸡{0}只,母鸡{1}只,小鸡{2}只", cock, hen, chick);
                    }
                }
            }
        }
    }
}

5、水仙花数

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cube
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = 100;
            Console.Write("水仙花数有:");
            do
            {
                int x = num / 100;//百位baidu
                int y = num % 100 / 10;//十位
                int z = num % 10;//个位
                if (x * x * x + y * y * y + z * z * z == num)
                {
                    Console.Write(" {0} ",num);
                }
                num += 1;
            } while (num < 1000);
        }
    }
}

6、学生出生日期-----DateTime类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentDataTime
{
    enum WeekDayhz { 星期日, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六 };
    class Program
    {
      class Student			
        {
            public string number;		//学号
            public string name;	//姓名
            public DateTime birthday;	//出生日期
            public void SetInfo(string xh, string xm, DateTime sr)
            {
                number = xh;
                name = xm;
                birthday = sr;
            }
            public void GetInfo()
            {

                Console.WriteLine("学号是{0}的学生的姓名是{1},出生日期为{2};", number, name,birthday);
            }
        }
        static void Main(string[] args)
        {
            Student s1, s2;
            s1 = new Student();
            s2 = new Student();
            DateTime birthday1 = new DateTime(1995, 10, 18);
            DateTime birthday2 = new DateTime(1996, 2, 16);
            s1.SetInfo("101","张三",birthday1);
            s2.SetInfo("102","李四",birthday2);
            s1.GetInfo();
            s2.GetInfo();
            int i = (int)s1.birthday.DayOfWeek;
            Console.WriteLine("{0}出生在{1}", s1.name, (WeekDayhz)i);
            i = (int)s2.birthday.DayOfWeek;
            Console.WriteLine("{0}出生在{1}", s2.name, (WeekDayhz)i);
            Console.WriteLine("{0}和{1}相差{2}天", s1.name, s2.name, s2.birthday - s1.birthday);
        }
    }
}

7、判断给定的词语是否在句子中------string

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FindWord
{
    class Program
    {
        static void Main(string[] args)
        {
            string sentence = "我希望有个如你一般的人 如山间清爽的风 如古城温暖的光 从清晨到夜晚 由山野到书房 只要最后是你就好";
            Console.Write("请输入要检索的词语:");
            string word = Console.ReadLine();
            if (sentence.IndexOf(word)>=0)
            {
                Console.WriteLine("词语“{0}”在句子“{1}”中!",word,sentence); 
            }
            else
            {
                Console.WriteLine("在句子中没有找到词语“{0}”,请重新输入检索词!", word);
            }

        }
    }
}

8、修改班级的班主任和总人数-----引用类型

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reference
{
    struct Class   //声明结构类型班级Class 
    {
        public Information stuIfo;  //学生信息
        public string teacher;  //班主任
    };
    class Information
    {
        public int sumNum; //总数量
    }

class Program
    {
        static void Main(string[] args)
        {
            Class class1, class2;
            Information stuInfo1 = new Information();
            stuInfo1.sumNum = 30;
            class1.stuIfo = stuInfo1;
            class1.teacher = "Marry";
            Console.WriteLine("一班的班主任是:{0}", class1.teacher);
            Console.WriteLine("一班的总人数是:{0}", class1.stuIfo.sumNum);

            Console.WriteLine("\n");
            Console.WriteLine("将一班的信息赋值给二班!");
            Console.WriteLine("\n");
            class2 = class1;
            Console.WriteLine("修改二班的班主任信息!");
            class2.teacher = "Tom";
            Console.WriteLine("二班的班主任是{0}:", class2.teacher);
            Console.WriteLine("修改二班的学生人数!");
            class2.stuIfo.sumNum = 31;
            Console.WriteLine("二班的总人数是:{0}", class2.stuIfo.sumNum);
            Console.WriteLine("\n");
            Console.WriteLine("一班的班主任是{0},总人数是{1}:", class1.teacher,class1.stuIfo.sumNum);



        }
    }
}

9、学生信息初始化----构造函数

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudentInfo
{
    class Student
    {
        public string number;       //学号
        public string name; //姓名
        public string sclass;   //班级
        public Student(string xh, string xm, string bj)
        {
            number = xh;
            name = xm;
            sclass = bj;
        }
        public void GetInfo()
        {
            Console.WriteLine("类Student中学号是{0}的学生的姓名是{1},来自{2};", number, name, sclass);
        }
    }

    struct SStudent
    {
        public string number;       //学号
        public string name; //姓名
        public string sclass;   //班级
        public void SetInfo(string xh, string xm, string bj)
        {
            number = xh;
            name = xm;
            sclass = bj;
        }
        public void GetInfo()
        {
            Console.WriteLine("结构类型SStudent中学号是{0}的学生的姓名是{1},来自{2};", number, name, sclass);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Student s1 = new Student("101", "张三", "信息191");
            Console.WriteLine("请输出学生s1的信息:");
            s1.GetInfo();
            Console.WriteLine("");
            Student s2 = s1;
            s2.number = "102";
            s2.name = "王小花";
            Console.WriteLine("请输出学生s1的信息:");
            s1.GetInfo();
            Console.WriteLine("");
            Console.WriteLine("请输出学生s2的信息:");
            s2.GetInfo();
            Console.WriteLine("");
            SStudent ss1 = new SStudent();
            ss1.SetInfo("201", "云朵朵", "信息192");
            Console.WriteLine("请输出学生ss1的信息:");
            ss1.GetInfo();
            Console.WriteLine("");
            SStudent ss2 = ss1;
            ss2.number = "202";
            ss2.name = "令狐花";
            Console.WriteLine("请输出学生ss1的信息:");
            ss1.GetInfo();
            Console.WriteLine("");
            Console.WriteLine("请输出学生ss2的信息:");
            ss2.GetInfo();
            Console.WriteLine("");
        }
    }
}

10、计算不同员工的工资-----方法重载

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ReloadFunction
{
    class Program
    {
        class Employee
        {
            int no;
            string name;
            string professionalTitle;
            public Employee()
            { }
            public Employee(int bh, string xm, string jb)
            {
                no = bh;
                name = xm;
                professionalTitle = jb;
            }
            public void GetIfo(int basesalary)
            {
                Console.WriteLine("编号{0},姓名{1},职称为{2},薪水为:基本工资{3}元", no, name, professionalTitle, basesalary);
            }
            public void GetIfo(int basesalary, int housingAllowance)
            {
                Console.WriteLine("编号{0},姓名{1},职称为{2},薪水为:基本工资{3}元+住房补贴{4}元={5}元", no, name, professionalTitle, basesalary, housingAllowance, basesalary + housingAllowance);
            }
            public void GetIfo(int basesalary, int housingAllowance, int reward)
            {
                Console.WriteLine("编号{0},姓名{1},职称为{2},薪水为:基本工资{3}元+住房补贴{4}元+奖金{5}元={6}元", no, name, professionalTitle, basesalary, housingAllowance, reward, basesalary + housingAllowance + reward);
            }
        }
        static void Main(string[] args)
        {
            Employee e1 = new Employee(001, "张三", "研究员");
            Employee e2 = new Employee(002, "李四", "工程师");
            Employee e3 = new Employee(003, "王五", "高级工程师");
            e1.GetIfo(1000);
            e2.GetIfo(1200, 500);
            e3.GetIfo(2000, 1000, 2000);

        }
    }
}

11、计算两点之间距离------引用型参数

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CalculateDistance
{
    class Program
    {
        class Point
        {
            double x;
            double y;

            public double X
            {
                get { return x; }
                set { x = value; }
            }
            public double Y
            {
                get { return y; }
                set { y = value; }
            }

            public void Eu_distance(Point p1)
            {
                double result;
                result = Math.Sqrt(Math.Pow((x - p1.x), 2) + Math.Pow((y - p1.y), 2));
                Console.WriteLine("点({0},{1})和点({2},{3})之间的欧式距离是:{4}",x,y,p1.x,p1.y,result);
            }

            public void MH_distance(Point p1)
            {
                double result;
                result = Math.Abs(x - p1.x) + Math.Abs(y - p1.y);
                Console.WriteLine("点({0},{1})和点({2},{3})之间的曼哈顿距离是:{4}", x, y, p1.x, p1.y, result);
            }

            public void Cos_distance(Point p1)
            {
                double result;
                result = (x * p1.x + y * p1.y) / (Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)) * Math.Sqrt(Math.Pow(p1.x, 2) + Math.Pow(p1.y, 2)));
                Console.WriteLine("点({0},{1})和点({2},{3})之间的余弦距离是:{4}", x, y, p1.x, p1.y, result);
            }     
                        		
        }
        static void Main(string[] args)
        {
            Point p = new Point();
            Point p1 = new Point();
            p.X = 1;
            p.Y = 1;
            p1.X = 2;
            p1.Y = 2;
            p.Eu_distance(p1);
            p.MH_distance(p1);
            p.Cos_distance(p1);

        }
    }
}

12、显示学生所选课程的信息-------对象交互

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InteractionObject
{
    class Program
    {
        class Student
        {
            string id;
            string name;
            int scredits;
            Course course;
            
            public Student(string id, string name, int scredits, Course course)
            {
                this.id = id;
                this.name = name;
                this.scredits = scredits;
                this.course = course;
            }

            public void UpdateCredit()
            {
                scredits += course.Credits; 
            }

            public void display()
            {
                Console.WriteLine("该生的学号是{0},姓名是{1},已选择了《{2}》课,这门课的课程号是{3},{4}学分,由{5}讲授,现在该生的总学分数是{6}"
                    ,id,name,course.Name,course.Cid,course.Credits,course.Teacher,scredits);

            }
        }

        class Course
        {
            string cid;
            string cname;
            int credits;
            string teacher;
            
            public Course(string cid,string cname,int credits,string teacher)
            {
                this.cid = cid;
                this.cname = cname;
                this.credits = credits;
                this.teacher = teacher;

            }

            public string Cid
            {
                get { return cid; }
            }
            public string Name
            {
                get { return cname; }
            }
            public int Credits
            {
                get { return credits; }
            } 
            public string Teacher
            {
                get { return teacher; }
            }
        }
        static void Main(string[] args)
        {
            Course c = new Course("Scl178","高阶英语",4,"Marry");
            Student s = new Student("101","王明",30,c);
            s.UpdateCredit();
            s.display();
        }
    }
}

13、输出学生信息-----继承

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inheritance1
{
    class Teacher
    {
        string tid;
        string tname;
        public Teacher(string tid,string tname)
        {
            this.tid = tid;
            this.tname = tname;
        }
        public string Tid
        { 
            get
            {
                return tid;
            } 
        }
        public string Tname
        {
            get
            {
                return tname;
            }
        }
    }
    class Advisor:Teacher
    {
        string major;
        public Advisor(string tid,string tname,string major):base(tid,tname)
        { this.major = major; }
        public string Major
        {
            get
            {
                return major;
            }
        }
    }
    class Student
    {
        protected string sid;
        protected string sname;
        public Student(string sid, string sname)
        {
            this.sid = sid;
            this.sname = sname;
        }
    }
    class UnderGraduate : Student
    {
        Teacher teacher;
        public UnderGraduate(string sid, string sname, Teacher teacher) : base(sid, sname)
        { this.teacher = teacher; }
        public void Udisplay()
        {
            Console.WriteLine("该生学号:{0},姓名:{1};他班主任的工号:{2},姓名:{3}。",sid,sname,teacher.Tid,teacher.Tname);
        }
    }
    class Graduate : Student
    {
        Advisor advisor;
        public Graduate(string sid, string sname, Advisor advisor) : base(sid, sname)
        { this.advisor = advisor; }
        public void Gdisplay()
        {
            Console.WriteLine("该生学号:{0},姓名:{1};他导师的工号:{2},姓名:{3},研究方向:{4}。",sid,sname, advisor.Tid, advisor.Tname, advisor.Major);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Teacher t = new Teacher("2020112", "Marry");
            UnderGraduate ug = new UnderGraduate("20200101", "Rose",t);
            ug.Udisplay();
            Advisor a = new Advisor("2018111", "Jim", "信息行为");
            Graduate g = new Graduate("20200201", "Jack", a);
            g.Gdisplay();
        }
    }
}

14、计算圆柱体表面积------派生类的构造函数

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ploymorphism
{
     class Circle
    {
        protected double radius;
        public Circle(double bj)
        {
            radius = bj;
        }
        public  double CircleArea()
        {
            return Math.PI * radius * radius;
        }
    }
    class Cylinder : Circle
    {
        double high;
        public Cylinder(double r, double h)
            : base(r)
        {
            high = h;
        }
        public double CylinderArea()
        {
            return base.CircleArea() * 2 + 2 * Math.PI * radius * high;
        }
    }
    
    class Program
    {
        static void Main(string[] args)
        {
            Circle circle = new Circle(100);
            Console.WriteLine("半径为100的圆的面积为{0:N2}", circle.CircleArea());
            Cylinder cylinder = new Cylinder(100, 100);
            Console.WriteLine("半径为100,高为100的圆柱体的表面积为{0:N2}", cylinder.CylinderArea());          
        }
    }
}

15、计算圆柱体和圆锥体表面积-----多态

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ploymorphism
{
     class Circle
    {
        protected double radius;
        public Circle(double bj)
        {
            radius = bj;
        }
        public virtual double Area()
        {
            return Math.PI * radius * radius;
        }
    }
    class Cylinder : Circle
    {
        double high;
        public Cylinder(double r, double h)
            : base(r)
        {
            high = h;
        }
        public override double Area()
        {
            return base.Area() * 2 + 2 * Math.PI * radius * high;
        }
    }
    class Cone : Circle
    {
        double high;
        public Cone(double r, double h)
            : base(r)
        {
            high = h;
        }
        public override double Area()
        {
            return base.Area() + Math.PI * radius * Math.Sqrt(radius * radius + high * high);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Circle cylinder = new Cylinder(100, 100);
            Console.WriteLine("半径为100,高为100的圆柱体的表面积为{0:N2}", cylinder.Area());
            Circle cone = new Cone(100, 100);
            Console.WriteLine("半径为100,高为100的圆锥体的表面积为{0:N2}", cone.Area());
        }
    }
}

16、输出不同员工的工资-----new或者虚方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Proj7_1
{
    class Program
    {
        public class Employee
        {
            int no;
            string name;
            int lengthofservice;
            const double basesalary = 1000;
           // double realsalary;
            public int No
            {
                get { return no; }
                set { no = value; }
            }
 
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
 
            public virtual double SetRealSalary()
            {
                Console.Write("请输入此人的工龄:");
                lengthofservice = int.Parse(Console.ReadLine());
                double realsalary = basesalary + 30 * lengthofservice;
                return realsalary;
            }
        }

        public class UEmployee:Employee
        {
            public override double SetRealSalary()
            {
               return base.SetRealSalary() * 2;
            }
        }

        public class GEmployee : UEmployee
        {
            public override double SetRealSalary()
            {
                return base.SetRealSalary() * 1.5;
            }
        }
        static void Main(string[] args)
        {
            Employee s1 = new Employee();
            s1.No = 101;
            s1.Name = "张三";
            Console.WriteLine("普通职工 工号:{0}  姓名:{1}",s1.No,s1.Name);
            Console.WriteLine("此人的实际工资为:{0}", s1.SetRealSalary());
            Console.WriteLine();

            UEmployee s2 = new UEmployee();
            s2.No = 201;
            s2.Name = "李四";
            Console.WriteLine("本科生职工 工号:{0}  姓名:{1}", s2.No, s2.Name);
            Console.WriteLine("此人的实际工资为:{0}", s2.SetRealSalary());
            Console.WriteLine();

            GEmployee s3 = new GEmployee();
            s3.No = 301;
            s3.Name = "王五";
            Console.WriteLine("研究生职工 工号:{0}  姓名:{1}", s3.No, s3.Name);
            Console.WriteLine("此人的实际工资为:{0}", s3.SetRealSalary());
        }
    }
}

17、图书馆管理学生借书权限----抽象类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AbstructClass
{
    abstract class Student
    {
        public abstract void Authority();
    }
    class Undergraduate : Student
    {
        public override void Authority()
        {
            Console.WriteLine("本科生可以借5本书");
        }
    }
    class Postgraduate : Student
    {
        public override void Authority()
        {
            Console.WriteLine("硕士生可以借8本书");
        }
    }
    class Doctor : Student
    {
        public override void Authority()
        {
            Console.WriteLine("博士生可以借10本书");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Undergraduate s1 = new Undergraduate();
            s1.Authority();
            Postgraduate s2 = new Postgraduate();
            s2.Authority();
            Doctor s3 = new Doctor();
            s3.Authority();

        }
    }
}

18、教师和学生信息的显示----抽象类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace duotai1
{
    abstract class Person
    {
        protected string no;
        protected string name;

        abstract public string No
        { set;}

        abstract public string Name
        { set;}

        abstract public void Display();
    }

    class Student : Person
    {
        string grade;
        public override string No
        { set { no = value; } }

        public override string Name
        { set { name = value; } }

        public string Grade
        { set { grade = value; } }

        public override void Display()
        {
            Console.WriteLine("学生的学号是{0},姓名是{1},班级是{2}!",no, name,grade);
        }

    }

    class Teacher : Person
    {
        string professionalTitle;
        string department;
        public override string No
        { set { no = value; } }

        public override string Name
        { set { name = value; } }

        public Teacher(string no, string name, string professionalTitle, string department)
        {
            this.no = no;
            this.name = name;
            this.professionalTitle = professionalTitle;
            this.department = department;
        }
        public override void Display()
        {
            Console.WriteLine("教师的学号是{0},姓名是{1},是{2}的{3}!", no, name, department, professionalTitle);
        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            Student s = new Student();
            s.No = "19111701";
            s.Name = "Mary";
            s.Grade = "信息161";
            s.Display();
            Teacher t = new Teacher("2017001","Tom","副教授","信息管理系");
            t.Display();
        }
    }
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

面向对象程序设计实验考试 的相关文章

  • 部署 MVC4 项目时出错:找不到文件或程序集

    过去 我只需使用 Visual Studio 2012 发布到 AWS 菜单项即可部署我的 MVC4 网站 到 AWS Elastic Beanstalk 现在 程序可以在本地编译并运行 但无法部署 从消息来看 它似乎正在寻找不在当前部署的
  • ROWNUM 的 OracleType 是什么

    我试图参数化所有现有的 sql 但以下代码给了我一个问题 command CommandText String Format SELECT FROM 0 WHERE ROWNUM lt maxRecords command CommandT
  • C++:无法使用scoped_allocator_adaptor传播polymorphic_allocator

    我有一个vector
  • 自动从 C# 代码进行调试过程并读取寄存器值

    我正在寻找一种方法来读取某个地址的 edx 注册表 就像这个问题中所问的那样 读取eax寄存器 https stackoverflow com questions 16490906 read eax register 虽然我的解决方案需要用
  • 如何在C++中实现模板类协变?

    是否可以以这样一种方式实现类模板 如果模板参数相关 一个对象可以转换为另一个对象 这是一个展示这个想法的例子 当然它不会编译 struct Base struct Derived Base template
  • 嵌入式系统中的malloc [重复]

    这个问题在这里已经有答案了 我正在使用嵌入式系统 该应用程序在 AT91SAMxxxx 和 cortex m3 lpc17xxx 上运行 我正在研究动态内存分配 因为它会极大地改变应用程序的外观 并给我更多的力量 我认为我唯一真正的路线是为
  • C# 中值类型和引用类型有什么区别? [复制]

    这个问题在这里已经有答案了 我知道一些差异 值类型存储在堆栈上 而引用类型存储在托管堆上 值类型变量直接包含它们的值 而引用变量仅包含对托管堆上创建的对象位置的引用 我错过了任何其他区别吗 如果是的话 它们是什么 请阅读 堆栈是一个实现细节
  • 跨多个控件共享事件处理程序

    在我用 C 编写的 Windows 窗体应用程序中 我有一堆按钮 当用户的鼠标悬停在按钮上时 我希望按钮的边框发生变化 目前我有以下多个实例 每个按钮一个副本 private void btnStopServer MouseEnter ob
  • 将字符串从非托管代码传递到托管

    我在将字符串从非托管代码传递到托管代码时遇到问题 在我的非托管类中 非托管类 cpp 我有一个来自托管代码的函数指针 TESTCALLBACK FUNCTION testCbFunc TESTCALLBACK FUNCTION 接受一个字符
  • HttpClient 像浏览器一样请求

    当我通过 HttpClient 类调用网站 www livescore com 时 我总是收到错误 500 可能服务器阻止了来自 HttpClient 的请求 1 还有其他方法可以从网页获取html吗 2 如何设置标题来获取html内容 当
  • 按字典顺序对整数数组进行排序 C++

    我想按字典顺序对一个大整数数组 例如 100 万个元素 进行排序 Example input 100 21 22 99 1 927 sorted 1 100 21 22 927 99 我用最简单的方法做到了 将所有数字转换为字符串 非常昂贵
  • A* 之间的差异 pA = 新 A;和 A* pA = 新 A();

    在 C 中 以下两个动态对象创建之间的确切区别是什么 A pA new A A pA new A 我做了一些测试 但似乎在这两种情况下 都调用了默认构造函数 并且仅调用了它 我正在寻找性能方面的任何差异 Thanks If A是 POD 类
  • 像“1$”这样的位置参数如何与 printf() 一起使用?

    By man I find printf d width num and printf 2 1 d width num 是等价的 但在我看来 第二种风格应该与以下相同 printf d num width 然而通过测试似乎man是对的 为什
  • C 中的位移位

    如果与有符号整数对应的位模式右移 则 1 vacant bit will be filled by the sign bit 2 vacant bit will be filled by 0 3 The outcome is impleme
  • 将日期参数传递给对 MVC 操作的 ajax 调用的安全方法

    我有一个 MVC 操作 它的参数之一是DateTime如果我通过 17 07 2012 它会抛出一个异常 指出参数为空但不能有空值 但如果我通过01 07 2012它被解析为Jan 07 2012 我将日期传递给 ajax 调用DD MM
  • 如何构建印度尼西亚电话号码正则表达式

    这些是一些印度尼西亚的电话号码 08xxxxxxxxx 至少包含 11 个字符长度 08xxxxxxxxxxx 始终以 08 开头 我发现这个很有用 Regex regex new Regex 08 0 9 0 9 0 9 0 9 0 9
  • ListDictionary 类是否有通用替代方案?

    我正在查看一些示例代码 其中他们使用了ListDictionary对象来存储少量数据 大约 5 10 个对象左右 但这个数字可能会随着时间的推移而改变 我使用此类的唯一问题是 与我所做的其他所有事情不同 它不是通用的 这意味着 如果我在这里
  • 方法参数内的变量赋值

    我刚刚发现 通过发现错误 你可以这样做 string s 3 int i int TryParse s hello out i returns false 使用赋值的返回值是否合法 Obviously i is but is this th
  • 如何在 C# 中播放在线资源中的 .mp3 文件?

    我的问题与此非常相似question https stackoverflow com questions 7556672 mp3 play from stream on c sharp 我有音乐网址 网址如http site com aud
  • 将变量分配给另一个变量,并将一个变量的更改反映到另一个变量中

    是否可以将一个变量分配给另一个变量 并且当您更改第二个变量时 更改会瀑布式下降到第一个变量 像这样 int a 0 int b a b 1 现在 b 和 a 都 1 我问这个问题的原因是因为我有 4 个要跟踪的对象 并且我使用名为 curr

随机推荐

  • Python将txt文件内容转换成列表

    参考 Python将txt文件内容转换成列表 云 社区 腾讯云 方法一 coding utf 8 f open r ip txt r a list f print a f close 方法二 coding utf 8 f open r ip
  • Sublime Text 3 安装Go语言相关插件gosublime《小白也能学会的教程》

    Sublime Text 3 安装Go语言相关插件gosublime 序言 这篇文章是自己的亲身体会 今天为了安装gosublime可是找了一堆教程 但大部分都无功于返 有些甚至点开后都是直接复制粘贴过来的 一度心灰意冷 就在我快要暴躁的时
  • Java 实现 QQ 登陆

    点击上方蓝色字体 选择 标星公众号 优质文章 第一时间送达 1 前言 个人网站最近增加了评论功能 为了方便用户不用注册就可以评论 对接了 QQ 和微博这 2 大常用软件的一键登录 总的来说其实都挺简单的 可能会有一点小坑 但不算多 完整记录
  • C++ Primer Exercise 5.18

    Understanduing the difference between C and C therefore know the computer language deeper vector
  • MySQL数据库锁的实现原理(面试)

    mysql的锁类型 一般其实就是表锁 行锁和页锁 一般myisam会加表锁 就是myisam引擎下 执行查询的时候 会默认加个表共享锁 也就是表读锁 这个时候别人只能来查 不能写数据的 然后myisam写的时候 也会加个表独占锁 也就是表写
  • 如何查看宝塔面板入口?

    终端输入 bt default
  • 【实例】python中简单分句,通过替代句号 &给句尾(不是句首)添加序号

    gt gt gt fn open E 西方哲学史 txt read gt gt gt fn fn replace t r n gt gt gt s open E 西方哲学史分句 txt w gt gt gt s s write fn 想要给
  • 蓝桥杯2018年第九届真题——乘积尾零

    乘积尾零 一 题目内容 本题为填空题 只需要算出结果后 在代码中使用输出语句将所填结果输出即可 如下的 10 行数据 每行有 10 个整数 请你求出它们的乘积的末尾有多少个零 5650 4542 3554 473 946 4114 3871
  • docker : unable to prepare context: context must be a directory

    1 美图 2 背景 创建了一个dockerfile base lcc lcc negix ll total 8 drwxr xr x 3 lcc staff 96 4 8 08 47 drwxr xr x 4 lcc staff 128 4
  • 介绍两种常见软件开发模式:“敏捷”和“瀑布”

    写在最前面 敏捷开发模式更加适合项目型的系统 瀑布开发模式更适合产品型系统 设计后多次迭代 以上属于个人理解 有不同的见解欢迎大家一起讨论 在软件开发时 经常面对的第一个项目实现决策是 我们应该使用哪种开发方法 这是一个引起很多讨论 和激烈
  • 图解Flink内核源码-尚硅谷大数据培训

    大佬硬核手撕Flink源码 首发内核源码图解 Flink内核源码大汇总 关注公众号 回复 Flink 还能获取全部内核讲解视频以及文档资料 1 Flink任务提交流程 相关文章 重磅 Flink源码解析环境准备及提交流程之环境准备重磅 Fl
  • XAMPP Mysql/MariaDB 忘记密码

    对于本地的本地的phpMyAdmin 忘记登录密码怎么办哪 看看下文 能省去你不少时间和精力 首先进入DOS 开一个cmd 第一步 先停掉MySQL服务 cmd命令行 c gt sc stop mysql XAMPP 手动点击MySQL g
  • 层次分析法模型(数学建模学习)

    本系列参考清风老师的数学建模课程 层次分析法模型 一 模型介绍 一 模型引入 对于方案选择类问题 评价类问题采用层次分析法 The ayalytic hierarchy process AHP 模型进行评分 之后评分高的就是最佳方案 二 模
  • Wireshark对SMTP抓包分析

    本文主要使用Wireshark对邮件客户端使用SMTP协议发送邮件的过程进行抓包分析并使用telnet命令进行简单操作 1 SMTP简介 简单邮件传输协议 英语 Simple Mail Transfer Protocol 缩写 SMTP 是
  • 《自然语言处理》-文本生成实验(基于MindSpore),避免的坑,保姆式教学

    最近我的导师去了解一下华为的MindSpore框架 觉得很有意思然后就让我跑一下他的文本生成实验 不过其中有很多是他的实验手册没怎么写清楚的点 我在这里为各位一个一个排坑拉 本实验都是来源于华为的文本生成实验手册 只是里面很多内容写的不清楚
  • 声速的测量的实验原理和应用_【声速测量】实验须知

    操作常见错误 1 忘记记录源频率f0 或选错源频率f0 每一台设备的源频率都不相同 在导轨左 右两侧可以找到 如下图为 37420 2 超声波的发射器和接受器端面不平行 甚至不与轨道垂直 解决办法 拧松发射器或接收器后面的螺丝 然后调整端面
  • 清除浮动伪元素/双伪元素

    清除浮动 问题 在做浮动布局的时候 如果父级盒子嵌套了子级盒子 如果父级盒子没有设置固定的高度 那么里面的子级盒子浮动以后 父级盒子的高度就不会被撑开 显示默认的高度为0就会影响后面的盒子显示布局 说明 用浮动布局的时候我们必须要嵌套一个父
  • Linux创建LVM分区与扩容

    1 划分物理磁盘格式 针对要增加的硬盘进行格式化 fdisk dev sdb 欢迎使用 fdisk util linux 2 23 2 更改将停留在内存中 直到您决定将更改写入磁盘 使用写入命令前请三思 Device does not co
  • 通用业务平台设计(三):自动化打包平台建设

    前言 在上家公司 随着业务的不断拓展 需要打多个包来支持业务的快速发展 这篇文章主要为大家分享在构建自动化打包平台过程中一些经验总结以及躺过的坑 通用业务平台系列 通用业务平台设计 一 概览 通用业务平台设计 二 扩展多国家业务 通用业务平
  • 面向对象程序设计实验考试

    1 圆的面积 namespace CircleArea class Program static void Main string args const double PI 3 1415926 double Radius Area Cons