日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

c语言side输出空心正方形,请帮忙完成这个c#语言打印正方形的程序

發布時間:2024/1/8 C# 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言side输出空心正方形,请帮忙完成这个c#语言打印正方形的程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

程序:

using System;

using System。Collections。Generic;

using System。Text;

namespace c

{

class Point

{

public int x;

public int y;

public Point(int nx, int ny)

{

Set(nx, ny);

}

public Point(Point n)

{

Set(n);

}

public void Set(int nx, int ny)

{

x = nx;y = ny;

}

public void Set(Point n)

{

x = n。

x;

y = n。y;

}

public int getx()

{

return x;

}

public int gety()

{

return y;

}

}

class Class1

{

private int side;

private Point location;

public Class1(Point location,int length)

{

this。

side = length;

this。location = location;

graph(location, length);

}

public void Class(Point center,int length)

{ }

public void graph(Point center,int length)

{

for(int i = 0; i = center。

x * 2 && (j - center。x * 2) % 2 == 0) line+="*";

else line+=" ";

}

else

{

if(j == center。

x * 2 || j == center。x * 2 + length * 2 - 2) line+="*";

else line+=" ";

}

}

Console。WriteLine(line);

}

}

public int getarea()

{

return side*side;

}

public int getperimeter()

{

return side*4;

}

public int getlength()

{

return side;

}

public Point getlocation()

{

return location;

}

}

class program

{

static void Main(string[] args)

{

int x, y, a;

Console。

WriteLine("請輸入正方形的邊長及位置:");

Console。WriteLine("邊長:");

a = int。Parse(Console。ReadLine());

Console。WriteLine("位置:");

x = int。

Parse(Console。ReadLine());

y = int。Parse(Console。ReadLine());

Class1 sd = new Class1(new Point(x, y), a);

Console。

WriteLine("Square:");

Console。WriteLine("Length=" + sd。getlength());

Console。WriteLine("Location=" + sd。getlocation()。

getx() + "," + sd。getlocation()。gety());

Console。WriteLine("Perimeter=" + sd。getperimeter());

Console。WriteLine("Area=" + sd。

getarea());

}

}

}

疑問:

1、

public void Class(Point center,int length)

{ }

這個函數不知道有什么用。

2、

函數Class還有下面這個函數

public void graph(Point center,int length)

{ }

不知道第一個參數叫center有什么用意沒有。

算出中心再做圖有什么好處嗎?

3、

using System。Collections。Generic;

我的程序里沒用上這個命名空間。

不知道這個命名空間是否提供了什么能讓程序簡化?

4、

x軸上的坐標都是2個字節算1個單位吧?現在是按這樣處理的。

5、

Console。WriteLine("Location=" + sd。getlocation()。getx() + sd。getlocation()。gety());

這句的輸出少了x和y之間的","。

全部

總結

以上是生活随笔為你收集整理的c语言side输出空心正方形,请帮忙完成这个c#语言打印正方形的程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。