错误 1 应输入 class、delegate、enum、interface 或 struct C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\ConsoleApplication6\ConsoleApplication6\Program.cs 6 8 ConsoleApplication6程序要求:
由用户选择输出哪个形状
用户给出某个形状的大小,如正方形的边长、长方形的长和宽、三角形的高度或边长(需有一定的长度限制)
用户选择用什么符号来画,默认为“*”
选做:用户选择输出实心还是空心图形using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;static void Square() //----------------------void下有红线
{
Console.Write("请输入正方形边长:");
int bc = Int32.Parse(Console.ReadLine()); Console.Write("是否实心:");
string sx = Console.ReadLine(); Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*"; for (int i = 0; i < bc; i++)
{
for (int j = 0; j < bc; j++)
{
if (sx == "Y" || sx == "y")
Console.Write(" "+fh);
if (sx == "N" || sx == "n")
{
if (i == 0 || i == bc - 1 || j == 0 || j == bc - 1)
Console.Write(" " + fh);
else
Console.Write(" ");
}
}
Console.WriteLine();
}
} static void Triangle() //----------------------void下有红线 {
Console.Write("请输入三角形边长:");
int bc = Int32.Parse(Console.ReadLine()); Console.Write("是否实心:");
string sx = Console.ReadLine(); Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*"; if (sx == "Y" || sx == "y")
{
for (int i = 0; i < bc; i++)
{
for (int j = 0; j < bc + i; j++)
{
if (j < bc - 1 - i)
Console.Write(" ");
else
Console.Write(" "+fh);
}
Console.WriteLine();
}
} if (sx == "N" || sx == "n")
{
for (int l = 0; l <bc; l++)
{
for (int k = 0; k < 2*bc-1; k++)
{
if (k + l == bc - 1 || k - l == bc - 1 || l == bc - 1)
Console.Write(" " + fh);
else
Console.Write(" ");
}
Console.WriteLine();
}
}
} static void Rectangle() //----------------------void下有红线 {
Console.Write("请输入长方形宽:");
int bc = Int32.Parse(Console.ReadLine()); Console.Write("请输入长方形长:");
int kd = Int32.Parse(Console.ReadLine()); Console.Write("是否实心:");
string sx = Console.ReadLine(); Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*"; for (int i = 0; i < bc; i++)
{
for (int j = 0; j < kd; j++)
{
if (sx == "Y" || sx == "y")
Console.Write(" " + fh);
if (sx == "N" || sx == "n")
{
if (i == 0 || i == bc - 1 || j == 0 || j == kd - 1)
Console.Write(" " + fh);
else
Console.Write(" ");
}
}
Console.WriteLine();
}
}不能通过编译
由用户选择输出哪个形状
用户给出某个形状的大小,如正方形的边长、长方形的长和宽、三角形的高度或边长(需有一定的长度限制)
用户选择用什么符号来画,默认为“*”
选做:用户选择输出实心还是空心图形using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;static void Square() //----------------------void下有红线
{
Console.Write("请输入正方形边长:");
int bc = Int32.Parse(Console.ReadLine()); Console.Write("是否实心:");
string sx = Console.ReadLine(); Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*"; for (int i = 0; i < bc; i++)
{
for (int j = 0; j < bc; j++)
{
if (sx == "Y" || sx == "y")
Console.Write(" "+fh);
if (sx == "N" || sx == "n")
{
if (i == 0 || i == bc - 1 || j == 0 || j == bc - 1)
Console.Write(" " + fh);
else
Console.Write(" ");
}
}
Console.WriteLine();
}
} static void Triangle() //----------------------void下有红线 {
Console.Write("请输入三角形边长:");
int bc = Int32.Parse(Console.ReadLine()); Console.Write("是否实心:");
string sx = Console.ReadLine(); Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*"; if (sx == "Y" || sx == "y")
{
for (int i = 0; i < bc; i++)
{
for (int j = 0; j < bc + i; j++)
{
if (j < bc - 1 - i)
Console.Write(" ");
else
Console.Write(" "+fh);
}
Console.WriteLine();
}
} if (sx == "N" || sx == "n")
{
for (int l = 0; l <bc; l++)
{
for (int k = 0; k < 2*bc-1; k++)
{
if (k + l == bc - 1 || k - l == bc - 1 || l == bc - 1)
Console.Write(" " + fh);
else
Console.Write(" ");
}
Console.WriteLine();
}
}
} static void Rectangle() //----------------------void下有红线 {
Console.Write("请输入长方形宽:");
int bc = Int32.Parse(Console.ReadLine()); Console.Write("请输入长方形长:");
int kd = Int32.Parse(Console.ReadLine()); Console.Write("是否实心:");
string sx = Console.ReadLine(); Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*"; for (int i = 0; i < bc; i++)
{
for (int j = 0; j < kd; j++)
{
if (sx == "Y" || sx == "y")
Console.Write(" " + fh);
if (sx == "N" || sx == "n")
{
if (i == 0 || i == bc - 1 || j == 0 || j == kd - 1)
Console.Write(" " + fh);
else
Console.Write(" ");
}
}
Console.WriteLine();
}
}不能通过编译
public class CalssName
{}
应该对了吧!试试
{ } ClassName 要与你的文件名同名
如:
public class class1
{
.
.
.
static void Rectangle()
{
}
}