帮我写注释 然后写作业 和意义

程序小海 2010-03-22 08:09:37
struct Student
{
string name;
int[] score;
public Student(string name,int[] score)
{
//指向自身的指针
this.name = name;
this.score = score;
}
//计算平均分数
public float avg()
{
float num = 0.0f;
for (int i = 0; i < score.Length; i++)
{
num += score[i];
}
return num / score.Length;
}
public string Name
{
get { return name; }
}
public int[] Score
{
get { return score; }
set { score = value; }
}
}
namespace ConsoleApplication3
{
class StudentTest
{
public static void Main()
{
Student[] stu = new Student[3];
string[] name ={ "jack", "mary", "kate" };
int[] s ={ 80, 80, 80 };
for (int i = 0; i < 3; i++)
{
stu[i] = new Student(name[i], s);
Console.WriteLine("{0,10}{1,3}",stu[i].Name,stu[i].avg());
}
}
}
}


谢谢各位了 拜托!

对于结构 真的不是很懂 ……
...全文
221 33 打赏 收藏 转发到动态 举报
写回复
用AI写文章
33 条回复
切换为时间正序
请发表友善的回复…
发表回复
电脑帮帮手 2010-03-23
  • 打赏
  • 举报
回复
struct Student 
{
string name;声明下学生姓名
int[] score;学生成绩
public Student(string name,int[] score) 建立一个学生类
{
//指向自身的指针
this.name = name;
this.score = score;
}
//计算平均分数
public float avg()
{
float num = 0.0f;
for (int i = 0; i < score.Length; i++)把每个同学分数都加起来
{
num += score[i];
}
return num / score.Length;
返回学生平均成绩
}
public string Name
{
get { return name; }
}
public int[] Score
{
get { return score; }
set { score = value; }
}
}
namespace ConsoleApplication3
{
class StudentTest
{
public static void Main()
{
Student[] stu = new Student[3];
string[] name ={ "jack", "mary", "kate" };
int[] s ={ 80, 80, 80 };
for (int i = 0; i < 3; i++)
{
stu[i] = new Student(name[i], s);
Console.WriteLine("{0,10}{1,3}",stu[i].Name,stu[i].avg());通过控制台打印出来这三个同学的姓名以及平均分
}
}
}

}

其实你慢慢分析,就是一个学生信息,然后输入学生成绩,求出学生的平均分,就这样
CqCoder 2010-03-23
  • 打赏
  • 举报
回复
我要分数~~~~~~~~~~~~~~~~~~
Code従業員 2010-03-23
  • 打赏
  • 举报
回复
//指向自身的指针?哪啊,没有发现啊
24K純帥 2010-03-23
  • 打赏
  • 举报
回复
很简单的哇,结构体是学生的信息,avg是求平均成绩
wxm3630478 2010-03-23
  • 打赏
  • 举报
回复
晕 不要把结构struct 想的那么恐怖 ...跟类class的用法基本一样

平时都用class 没用过struct ,以为struct 是个什么厉害,高深的玩意儿
cyhf00808 2010-03-23
  • 打赏
  • 举报
回复
四字真言
TimDavid 2010-03-23
  • 打赏
  • 举报
回复
小少爷,你妈妈叫你回家吃饭了!
Baesky 2010-03-23
  • 打赏
  • 举报
回复
其实我想把每个字都翻译一下,但是写了3行注释后我忍不住全删了,我感觉耻辱,我感觉丢人,我感觉我神圣的职业被玷污....
benbenhuo 2010-03-23
  • 打赏
  • 举报
回复
楼主啊~~要在学校好好学习啊~~~
cjcgy 2010-03-23
  • 打赏
  • 举报
回复
我觉得lz还是装MM求助比较靠谱。
zilong4460072 2010-03-23
  • 打赏
  • 举报
回复
SB
别说你是大学生,丢中国农民的儿子的人
gsq_0912 2010-03-23
  • 打赏
  • 举报
回复
幫頂!!
影子_爱人 2010-03-23
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 feng0hua0 的回复:]
10分到手,走人.
[/Quote] 只有引用的内容不允许回复!
程序小海 2010-03-23
  • 打赏
  • 举报
回复
[Quote=引用 22 楼 baesky 的回复:]
其实我想把每个字都翻译一下,但是写了3行注释后我忍不住全删了,我感觉耻辱,我感觉丢人,我感觉我神圣的职业被玷污....
[/Quote]

你是天才!?

出生就又蹦又跳的!?

还是早产 ……
程序小海 2010-03-23
  • 打赏
  • 举报
回复
[Quote=引用 30 楼 telancs 的回复:]
期末作业?
[/Quote]

不是 就是一段代码 不理解
程序小海 2010-03-23
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 zilong4460072 的回复:]
SB
别说你是大学生,丢中国农民的儿子的人
[/Quote]

你TMD 没碰见过不懂啊!

有种 你不学 进微软啊!
telancs 2010-03-23
  • 打赏
  • 举报
回复
期末作业?
feng0hua0 2010-03-23
  • 打赏
  • 举报
回复
10分到手,走人.
睡神在睡觉 2010-03-23
  • 打赏
  • 举报
回复
原来学生可以这样。。。。后悔我当初怎么没想到这办法
xupeihuagudulei 2010-03-22
  • 打赏
  • 举报
回复
我X
我顶你倒可以
加载更多回复(13)

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧