c#编程题!!!
发布网友
发布时间:2023-04-08 10:23
我来回答
共2个回答
热心网友
时间:2024-12-02 04:02
第一题:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _1
{
class rectangle
{
private double width, height, S, L;
public rectangle(double w, double h)
{
width = w;
height = h;
double S = width * height;
double L = 2 * (width + height);
}
public double w{get;set;}
public double h{ get; set;}
public double GetArea()
{
return width * height;
}
public double GetPerimeter()
{
return 2 * (width + height);
}
public string Showinfo()
{
return string.Format("矩形的面积为:{0},周长为:{1}", S, L);
}
class Program
{
static void Main(string[] args)
{
rectangle rect1 = new rectangle(10, 5);
Console.WriteLine("矩形rect1的面积为:{0}", rect1.GetArea());
Console.WriteLine("矩形rect1的周长为:{0}", rect1.GetPerimeter());
Console.Read();
}
}
}
}
第四题:
protected int[] bubbleUp(int[] Array)
{
for (int i = 0; i < Array.Length; i++)
{
for (int j = i+1; j < Array.Length; j++)
{
if (Array[i] > Array[j])
{
int temp=Array[i];
Array[i]=Array[j];
Array[j] = temp;
}
}
}
return Array;
}
热心网友
时间:2024-12-02 04:02
你好,你的这个程序什么要呢?是控制台程序?还是桌面程序