发布时间 : 星期二 文章C#试题库(全)附 参考答案更新完毕开始阅读
Console.WriteLine(\ Console.ReadLine(); } }
class Shape {
protected double width; protected double height; public Shape() {
width = height = 0; }
public Shape(double w, double h) {
width = w; height = h; }
public virtual double area() {
return width * height; } }
class Triangle : Shape {
public Triangle(double x, double y) : base(x, y) { }
public override double area() {
return width * height / 2; }
}
程序的输出结果是____area is 6____________________
11、class Program
{
static void Main(string[] args) {
Point p1 = new Point(); Point p2 = new Point(3, 4);
Console.WriteLine(\ Console.WriteLine(\ Console.ReadLine(); } } class Point {
public double x = 0, y = 0; public Point() {
x = 1; y = 1; }
public Point(double a, double b) { x = a; y = b; } }
程序最终的输出结果是___ p1.x=1,p1.y=1
p2.x=3,p2.y=4 __
12、class Program
{
static void Main(string[] args)
{
Triangle t = new Triangle(3, 4); double s = t.area();
Console.WriteLine(\ Console.ReadLine(); } }
class Shape {
protected double width; protected double height; public Shape() {
width = height = 0; }
public Shape(double w, double h) {
width = w; height = h; }
public virtual double area() {
return width * height; } }
class Triangle : Shape {
public Triangle(double x, double y) : base(x, y) { }
public override double area()
{
return width * height / 2; } }
程序最终的输出结果是_ area is 6__ 、class Program
{
static void Main(string[] args) {
MyClass m = new MyClass(); int a, b, c;
a = 0; b =20; c = 10; m.sort(ref a, ref b, ref c);
Console.WriteLine(\ Console.ReadLine(); } } class MyClass {
public void sort(ref int x, ref int y, ref int t) {
int tmp;
if (x > 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,10,20
程序的输出结果是_____ a=0,b=10,c=20 ______________________ 14、 class Program
13
{
static 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 Console .Write(\ } Console .ReadLine (); } } class MyClass { public void Array(int[] a) { for (int i = 0; i < a.Length; i++) { a[i] = i; } } } 程序最终的输出结果是01234567 _ 、class Program { enum Season : int { Spring, Summer , Autumn, Winter } static void Main(string[] args) { Season s = (Season)2; Console.WriteLine(s); Console.Read(); } } 程序的输出结果是________ Autumn ________________ 16、class Program { static void Main(string[] args) { int i = 0, sum = 0; do { sum++; } while (i > 0); Console.WriteLine(\ } } 程序的运行结果是_________ sum = 1________________ 17、static void Main(string[] args) { int x = 123; object obj1=x; x = x+100; Console.WriteLine (\ 15 } 程序的输出结果是_________ obj1=123___________ 18、下面程序的功能是:输出100以内能被3整除且个位数为6的所有整数,请填空。 static void Main(string[] args) { int j; for (int i = 0; i <= 9; i++) { j = i * 10 + 6; if (i % 10 !=6&&j%3!=0) Continue; Console.Write(\ } Console.Read(); } 19、using System; class Program { static void Main(string[] args) { int m, n, i, j, max = 0; Console.WriteLine(\请输入m,n的值\ m = Convert.ToInt32(Console.ReadLine ()); n = int.Parse(Console.ReadLine()); if (m < n) i = m; else i = n; for (j = i; j > 0; j--) if (m % j == 0 && n % j == 0) { max = j; break; } Console.WriteLine(\ Console.ReadLine(); } } 若分别从键盘输入8和6,则程序的运行结果是__ max=2___________________ 20、static void Main(string[] args) { int Sum = 0; for (int i = 1; i <= 10; i++) { if (i % 2 == 0) Sum += i; } Console.WriteLine(Sum); } 程序的输出结果是____30______ 21、 static void Main(string[] args) { int m, n,i; int[] a = new int[6]{1,2,5,3,9,7}; m = n = a[0]; for (i = 1; i < 6; i++) { if (a[i] > m) m = a[i]; if (a[i] < n) n = a[i]; } Console.WriteLine(\