C# 编写学生类Student,包含学生姓名,成绩,设计一个友员函数sortDegree(),将学生成绩按大到小排序。

作者&投稿:钊很 (若有异议请与网页底部的电邮联系)
有一个学生类student,包括学生姓名、成绩、设计一个友元函数,输出成绩大于等于80分以上者~

贴个大概出来。太晚了睡觉了。写完了发上来。
class Student;
typedef Student* pStudent;
#define INIT_SIZE 10;
class Teacher
{
private:
pStudent *pStu;
int n_count;
int n_next;
public:
Teacher();
void insert(Student& refstu);
void print() const;
void sort() const;
};

Teacher::Teacher()
{
pStu = malloc (sizeof(pStudent*)*INIT_SIZE);
assert(pStu==NULL);
n_count = INIT_SIZE;
n_next = 0;
}

Teacher::insert()
{
pStudent * p = NULL;
if(next>=n_count)
{
p = realloc(pStu,n_count+INIT_SIZE);//补内存、
}

}


class Student
{
private:
char* pName;
int m_Grade;
public:
Student();
Student(const char * str, int & grade);
Student(const Student& refstu);
Student& operator=(const Student& refstu);
friend void Teacher::print()const;
friend void Teacher::sort()const;
};

int main()
{}

MATCH(lookup_value,lookup_array,match_type);lookup_value是你要查找的值;lookup_array是你要查找的值所在的区域;match_type是匹配的类型; -1是查找大于或等于 lookup_value 的最小值;0是查找等于 lookup_value 的第一个值;1是查找小于或等于 lookup_value 的最大值。
1、打开要复制数据的表格。

2、可以看到总成绩那一列的数据使用公式生成的。

3、选择好要复制的数据,然后点击右键,点击【复制】。

4、在要粘贴的表格处单击鼠标右键,点击【选择性粘贴】。

5、弹出【选择性粘贴】对话框。

6、点击【数据】。点击【确定】。

// 学生类
    class Student:IComparer<Student>
    {
        private Student() { }
        public Student(string n, int d)
        {
            name = n;
            degree = d;
        }
        public string name { get; set; }
        public int degree { get; set; }
        static public IComparer<Student> getComparer()
        {
            return (IComparer<Student>)new Student();
        }
        int IComparer<Student>.Compare(Student x, Student y)
        {
            return y.degree - x.degree;
        }
    }
    //控制台代码
        class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            List<Student> l = new List<Student>();
            for (int i = 0; i < count; i++)
            {
                string str = Console.ReadLine();
                string name = str.Split(' ')[0];
                int degree = int.Parse(str.Split(' ')[1]);
                l.Add(new Student(name, degree));
            }
            sortDegree(l);
            foreach (Student s in l)
            {
                Console.WriteLine(String.Format("The student's name: {0} Degree: {1}", s.name, s.degree));
            }
            Console.ReadKey();
        }
            static public IEnumerable<Student> sortDegree(IEnumerable<Student> ie)
            {
                List<Student> l = (List<Student>)ie;
                l.Sort(Student.getComparer());
                return (IEnumerable<Student>)l;
            }
    }


class Student
{
public string name="";
public int degree=0;
public Student(){}
public Student( string _name, int _degree)
{
name=_name;
degree=_degree;
}
}
class Program
{
static void Main()
{
Console.WriteLine("请输入学生个数");
int length=int,Parse(Console.ReadLine());
int[] a=new int[length];
Console.WriteLine("请输入学生姓名与成绩 按空格隔开");
Dictionary<string,int> dict=new Dictionary<string,int>();
for(int i=0;i<a.Length;i++)
{
string s=Console.ReadLine();
int index=s.IndexOf(' ');
dict.Add(s.SubString(0,index),int.Parse(s.SubString(index+1)));
a[i]=int.Parse(s.SubString(index+1));
}
sortDegree(a);
}
static void sortDegree(int[] a)
{
for(int i=0;i<a.Length-1;i++)
{
for(int j=0;j<a.Length-1-i;j++)
{
if(a[j]<a[j+1])
{
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
}


兖州市17640658146: c#设计一个程序定义Student类 -
廉毓卫算: 我写了个样例,你看一下,先定义Studentpublic class Student{public string Name { get; set; }private DateTime _birthday;public DateTime Birthday{get { return _birthday; }set { _birthday = value; }}public int Age{get { return DateTime....

兖州市17640658146: c# 编写一个程序,实现学生信息的输入和输出. -
廉毓卫算: 关键代码我贴出,主函数main代码如下 { student stu = new student(); stu.input(); stu.say(); } 学生类student类如下 public class student { /// <summary> /// 学号 /// </summary> public string xh; public string name; public string banji; public int age; ...

兖州市17640658146: 设计一个学生类Student,成员变量包括ID(学号),Name(姓名),Age(年龄),Av -
廉毓卫算: 用C# 语言可以的 很简单的 using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace student {class Student{public string ID;public string Name;public int Age; } }

兖州市17640658146: c#中定义一个学生结构类型student,在这个结构类型中包括学号、姓名、年龄、出生、日期? -
廉毓卫算: public struct Student//结构类型 { public int Id;//学号 public string name;//姓名 public int age;//年龄 public Datetime time;//出生日期 }

兖州市17640658146: 编写一个C#应用程序,定义学生类Student及其派生类Undergraduate和Graduate,实现方法的重载和多态. -
廉毓卫算: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CShap_Test1 { class Student { public string Name { get; set; } public int Num { get; set; } public Student() :this("",0) { } public Student(string ...

兖州市17640658146: 在c#控制台创建student类!求高手!求代码!
廉毓卫算: 要求挺多的 我给你个思路 Student类单独一个文件 里面定义几个私有的你要的变量 给每个变量写属性索引器来实现访问 然后如果是用正则表达式验证输入的话 可以直接写到主程序代码里 也可以用微软的企业类库里的Validation.dll来验证 这个就写到student类里 如果没用过企业类库就写第一种验证吧 方便,简单 希望对你有用!

兖州市17640658146: 用C#设计一个学生类,该类能够记录学生姓名、出生年月、班级、成绩和科目等信息. -
廉毓卫算: class Project{ string proName; double proScore; }; class StudentInfor{ string stuName; dateTime stuBirth; string stuClass; Project projects[N]; };

兖州市17640658146: 在c#,利用封装实现以下功能.定义一个描述学生情况的类,包括学号、姓... -
廉毓卫算: class Program { static void Main(string[] args) { Student s = new Student() { Id = 1, Number = "00001", Name = "john", Sex = "man", Age = 21 }; s.SayHello(); } } interface IStudentAction { void UpdateAge(int age); void SayHello(); } public ...

兖州市17640658146: C#编程student类 -
廉毓卫算: 代码在图片上,自己动手敲敲代码吧,对自己有好处..NET3.0或更高版本,用到的是C#3.0语法.记事本写好代码后,用csc命令即可编译.

兖州市17640658146: 在控制台应用程序中创建一个Student类 -
廉毓卫算: class Student { private: string xuehao; string name; int age; bool sex; public: Student() { xuehao="0"; name="0"; age=0 sex=false; } Student(string newxuehao,string newname,int newage,string newsex) { bool tmp; if(newsex=="男") tmp=false...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网