c#读程序写结果和看程序填空

上传人:第*** 文档编号:33960883 上传时间:2018-02-19 格式:DOCX 页数:40 大小:72.50KB
返回 下载 相关 举报
c#读程序写结果和看程序填空_第1页
第1页 / 共40页
c#读程序写结果和看程序填空_第2页
第2页 / 共40页
c#读程序写结果和看程序填空_第3页
第3页 / 共40页
c#读程序写结果和看程序填空_第4页
第4页 / 共40页
c#读程序写结果和看程序填空_第5页
第5页 / 共40页
点击查看更多>>
资源描述

《c#读程序写结果和看程序填空》由会员分享,可在线阅读,更多相关《c#读程序写结果和看程序填空(40页珍藏版)》请在金锄头文库上搜索。

1、四、读程序写结果和看程序填空2、 class Programstatic void Main(string args)Elephant e = new Elephant(abc);Console.ReadLine();public class Animalpublic Animal()Console.Write (基类默认构造函数!);public Animal(string s)Console.Write (非默认构造函数);public class Elephant : Animalpublic Elephant()Console.Write (派生类构造函数!);public Eleph

2、ant(string str): base(str)Console.Write (str);程序的运行结果是_非默认构造函数 abc _3.在 Main 方法中需要调用 Display 方法,按照要求填空 class Programstatic void Main(string args)A1 a = new A1(); /创建 A1类的对象 aConsole.WriteLine(a.Display();Console.ReadLine();class A1public string Display()return hello everyone!;4、 下列程序完成了调用静态方法和实例方法,补

3、充空白处并写出运行结果class Programstatic void Main(string args)Example e1 = new Example();e1.meth1();Example.meth2(); /调用 meth2() Console.WriteLine(a=0,b=1,e1 .a ,Example .b);Console.ReadLine();class Examplepublic int a; static public int b;public void meth1()a = 10;b = 20;public static void meth2()b = 30;程序的

4、输出结果是_a=10,b=30_5、 class Programstatic void Main(string args)s s1 = new s();s t1 = new s();Console.ReadLine();public class spublic s()Console.Write (构造函数!);static s()Console .Write (静态构造函数!); 程序的运行结果是_静态构造函数!构造函数!构造函数!_6、 class Programstatic void Main(string args) Person p = new Person();p.N = www;C

5、onsole.WriteLine(p.N );Console.ReadLine();public class Personprivate string p_name=abc;public string Nget return p_name; set p_name = value; 程序最终的输出结果是_www_7、class Programstatic void Main(string args)B b = new B();A a = b;a.G();b.G();Console.Read();class A public virtual void G()Console.Write (A.G!)

6、; class B : Apublic override void G()Console.Write (B.G!);程序的输出结果是_ B.G!B.G!_8、 下列程序完成了输出数组中的最大值和最小值,请补充程序中的空白处class Programstatic void Main(string args)MyClass m = new MyClass();int s = 1, 6, 4, 7, 3, 87, 5 ;int smax, smin;m.MaxMin(s, out smax, out smin); Console.WriteLine(smax=0,smin=1,smax ,smin

7、);Console.ReadLine();class MyClasspublic void MaxMin(int a, out int max, out int min)max = min = a0;for (int i = 1; i max) max = ai;if (ai y) tmp = x; x = y; ;y = tmp; if (x t) tmp = x; x = t; t = tmp; if (y t) tmp = y; y = t; t = tmp; Console.WriteLine(0,1,2, x, y, t);程序的输出结果是_ a=0,b=10,c=20 _14、 c

8、lass Programstatic void Main(string args)MyClass m = new MyClass();int s = 34, 23, 65, 67, 54, 98, 6, 56 ;m.Array(s);for(int i=0;i 0);Console.WriteLine(sum = 0, sum);程序的运行结果是_ sum = 1_17、static void Main(string args) int x = 123;object obj1=x; x = x+100; Console.WriteLine ( obj1= 0 , obj1 ); 程序的输出结果

9、是_ obj1=123_18、下面程序的功能是:输出 100以内能被 3整除且个位数为 6的所有整数,请填空。 static void Main(string args)int j;for (int i = 0; i 0; j-)if (m % j = 0 & n % j = 0)max = j;break;Console.WriteLine(max=0, max);Console.ReadLine();若分别从键盘输入 8和 6,则程序的运行结果是_ max=2_ 20、static void Main(string args) int Sum = 0; for (int i = 1; i

10、max) m = ai;if (ai 0)case true :switch (b 0; j+)if (j % m = 0 & j % n = 0)s = j;break;Console.WriteLine(0, s);若从键盘上分别输入 4和 6,则程序最终的输出结果是_12_30、static void Main(string args)int pins = 9, 3, 7, 2 ;for (int index = 0; index != pins.Length; index+)int pin = pinsindex;System.Console.Write (pin);foreach (

11、int i in pins)Console.Write (i);程序的输出结果是_93729372_31、分析一下 C#代码,根据面向对象的多态性,代码的运行结果是_B_class Apublic void F()Console.Write(“A”); Public void F(string chr)Console .Write(“B”);class B:APublic void F()Console.write(“B”);Static void Main()B objB=new B();objB.F(); 32、分析如下 C# 代码,根据类的继承关系,运行后的输出结果是_不得入内 未成年人

12、_public class Personprivate int age=0;public int Agegetreturn age;setIf(value=18)Console.WriteLine(“成年人”);ElseConsole.WrteLine(“未成年人”);public class People:Personpublic People()Console.Write(“不得入内” ) ;class Teststatic void Main (stringargs)people shang=new People();shang.Age=1733、阅读下面程序,请确定枚举成员的关联值。e

13、num Color:uintRed,Green=3,Blue,Max=Blue(1) 枚举成员 Red 的关联值为(0)(2) 枚举成员 Green的关联值为(3)(3) 枚举成员 Blue的关联值为(4)(4) 枚举成员 Max的关联值为(4) 。34、写出以下程序的运行结果。_57_using System;class Test public static void Main()int x = 5;int y = x+;Console.Write (y);y=+x;Console.Write (y); 35、写出下列函数的功能。若 AB则返回 1,若 A=B则返回 0,若 Ab) retu

14、rn 1;else if (a=b) return 0;else return -1; 36、写出以下程序运行结果。9 12 15using System;class Teststatic int a = 1, 2, 3, 4, 5, 6, 7, 8 ;public static void Main()int s0, s1, s2;s0 = s1 = s2 = 0;for (int i = 0; i 50) break;if (i%2=0) s+=i; Console.WriteLine (i, s= + i + , + s); 39、 写出下列程序的运行结果。static void Main(string args)string words = new string “a”,”b”,”c”;foreach ( string w

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号