200高分求解5道题(C#)
下面是题目,只要写出的代码能运行就行了,谢谢大家!不知为什么只能设置100分,获得源码后我追加!================题目下载.doc格式,下载:{{http:...
下面是题目,只要写出的代码能运行就行了,谢谢大家!
不知为什么只能设置100分,获得源码后我追加!
================题目下载
.doc格式,下载:
{{
http://b2n4jg.tuk.livefilestore.com/y1pPJzFZD8_KrZg2jdfc3YAkZ7ctooLRAtKPd8AiddC0becSdxttDz_rhuPdxdXjxOWWHMlH-Dt-H2DFTEj1cYeGUwRy_UaIbS4/C%23%E9%A2%98%E7%9B%AE5%E9%81%93.doc?download
}}
或
http://cid-50531dfb545ee3f4.skydrive.live.com/browse.aspx/PublicForFriends?uc=1中的"C#题目5道"
================ 展开
不知为什么只能设置100分,获得源码后我追加!
================题目下载
.doc格式,下载:
{{
http://b2n4jg.tuk.livefilestore.com/y1pPJzFZD8_KrZg2jdfc3YAkZ7ctooLRAtKPd8AiddC0becSdxttDz_rhuPdxdXjxOWWHMlH-Dt-H2DFTEj1cYeGUwRy_UaIbS4/C%23%E9%A2%98%E7%9B%AE5%E9%81%93.doc?download
}}
或
http://cid-50531dfb545ee3f4.skydrive.live.com/browse.aspx/PublicForFriends?uc=1中的"C#题目5道"
================ 展开
10个回答
展开全部
using System;
namespace B5
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class B5
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Console.WriteLine(Square(2));
Console.WriteLine(Cube(2));
Console.WriteLine(Quartic(2));
Console.WriteLine(Quintic(2));
Student s1= new Student("李明");
s1.Grade=3;
Console.WriteLine(s1.ToString());
Student s2 = new Undergraduate("李明");
s2.Grade=5;
Console.WriteLine(s2.ToString());
Student s3 = new Graduate("王静");
Console.WriteLine(s3.ToString());
}
//------------------------------------------------------
static int Square( int num )
{
return num*num;
}
static int Cube( int num )
{
return num*num*num;
}
static int Quartic(int num)
{
return Square(num)*Square(num);
}
static int Quintic(int num)
{
return Square(num)*Cube(num);
}
}
//----------------------------------------------------------
//static int Max(int x,int y)
//----------------------------------------------------------
public class Student
{
public Student(string name)
{
m_name = name;
}
protected string m_name;
protected int m_age=20,m_grade=1;
/// <summary>
/// 年龄
/// </summary>
public int Age
{
get{return m_age;}
set{m_age=value;}
}
/// <summary>
/// 年级
/// </summary>
public int Grade
{
get{return m_grade;}
set{m_grade=value;}
}
public override string ToString()
{
return string.Format("{2}年级大学生{0},{1}岁",m_name,m_age,m_grade);
}
}
public class Undergraduate:Student
{
public Undergraduate(string name):base(name){}
public override string ToString()
{
return string.Format("{2}年级大学生{0},{1}岁",m_name,m_age,m_grade);
}
public new int Grade
{
get{return m_grade;}
set
{
if( value<1 || value>5 )
throw new Exception("设置时要求属性值在1~5之间");
m_grade = value;
}
}
}
public class Graduate:Student
{
public Graduate(string name):base(name){}
public new int Grade
{
get{return m_grade;}
set
{
if( value<1 || value>3 )
throw new Exception("设置时要求属性值在1~3之间");
m_grade = value;
}
}
public override string ToString()
{
return string.Format("{2}年级研究生{0},{1}岁",m_name,m_age,m_grade);
}
}
}
// BY SMalls
namespace B5
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class B5
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Console.WriteLine(Square(2));
Console.WriteLine(Cube(2));
Console.WriteLine(Quartic(2));
Console.WriteLine(Quintic(2));
Student s1= new Student("李明");
s1.Grade=3;
Console.WriteLine(s1.ToString());
Student s2 = new Undergraduate("李明");
s2.Grade=5;
Console.WriteLine(s2.ToString());
Student s3 = new Graduate("王静");
Console.WriteLine(s3.ToString());
}
//------------------------------------------------------
static int Square( int num )
{
return num*num;
}
static int Cube( int num )
{
return num*num*num;
}
static int Quartic(int num)
{
return Square(num)*Square(num);
}
static int Quintic(int num)
{
return Square(num)*Cube(num);
}
}
//----------------------------------------------------------
//static int Max(int x,int y)
//----------------------------------------------------------
public class Student
{
public Student(string name)
{
m_name = name;
}
protected string m_name;
protected int m_age=20,m_grade=1;
/// <summary>
/// 年龄
/// </summary>
public int Age
{
get{return m_age;}
set{m_age=value;}
}
/// <summary>
/// 年级
/// </summary>
public int Grade
{
get{return m_grade;}
set{m_grade=value;}
}
public override string ToString()
{
return string.Format("{2}年级大学生{0},{1}岁",m_name,m_age,m_grade);
}
}
public class Undergraduate:Student
{
public Undergraduate(string name):base(name){}
public override string ToString()
{
return string.Format("{2}年级大学生{0},{1}岁",m_name,m_age,m_grade);
}
public new int Grade
{
get{return m_grade;}
set
{
if( value<1 || value>5 )
throw new Exception("设置时要求属性值在1~5之间");
m_grade = value;
}
}
}
public class Graduate:Student
{
public Graduate(string name):base(name){}
public new int Grade
{
get{return m_grade;}
set
{
if( value<1 || value>3 )
throw new Exception("设置时要求属性值在1~3之间");
m_grade = value;
}
}
public override string ToString()
{
return string.Format("{2}年级研究生{0},{1}岁",m_name,m_age,m_grade);
}
}
}
// BY SMalls
展开全部
static int Square (int x){return x*x;}
static int Cube (int x){return x*x*x;}
static int Quartic (int x){return Square(Square(x));}
static int Quintic (int x){return Cube(Square(x));}
static double Max(double x,double y){return x>y?x:y}
到群32682173来吧..
static int Cube (int x){return x*x*x;}
static int Quartic (int x){return Square(Square(x));}
static int Quintic (int x){return Cube(Square(x));}
static double Max(double x,double y){return x>y?x:y}
到群32682173来吧..
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这种问题当然要去问老师了!
你问外行人怎么可能知道答案!
你问外行人怎么可能知道答案!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我以前学(C#)也遇到很多问题,问也问不出个所以然来,最好还是自己多看看书吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这题都难? 我晕... 刚学C#就做这些.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
太难了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询