using System;using System.Collections.Generic;using System.Text;namespace Proj6_18{class Student {int sno;string sname; Course[] course;int[] score; double sgpa1; double sgpa2; public int psno {get{ return sno; }set{ sno = value; }}public string psname{get{ return sname; }set{ sname = value; }}public void setcourse(params Course[] course1){course = new Course[course1.Length];for (int i = 0; i< course1.Length; i++)course[i] = course1[i];}public void setscore(int[] score1){score = new int[score1.Length];for (int i = 0; i< score1.Length; i++)score[i] = score1[i];}public void computegpa(){int i;double s, sumc = 0, sumgpa1 = 0, sumgpa2 = 0;for (i = 0; i< score.Length; i++){if (score[i] >= 90)s = 4.0;else if (score[i] >= 80)s = 3.0;else if (score[i] >= 70)s = 2.0;else if (score[i] >= 60)s = 1.0;elses = 0.0;sumgpa1 += course[i].pcredits * s;sumgpa2 += course[i].pcredits * score[i];sumc += course[i].pcredits;}sgpa1 = sumgpa1 / sumc;sgpa2 = sumgpa2 * 4 / sumc / 100;}public void dispstud()//输出学生e68a84e8a2ade799bee5baa6e997aee7ad9431333335313863信息{Console.WriteLine("学号:{0} 姓名:{1}", sno, sname);Console.WriteLine(" 课程名 学分 分数");for (int i = 0; i< course.Length; i++)Console.WriteLine(" {0} {1} {2}", course[i].pcname, course[i].pcredits, score[i]);}public void dispgpa() //输出GPA{Console.WriteLine("常见算法GPA={0:n},标准算法GPA={1:n}", sgpa1, sgpa2);}}class Course{string cname; int credits;public Course() { }public Course(string name, int xf){cname = name;credits = xf;}public string pcname {get{ return cname; }set{ cname = value; }}public int pcredits{get{ return credits; }set{ credits = value; }}}class Program{static void Main(string[] args){Course[] course1 = new Course[] {new Course("课程1",4),new Course("课程2",3), new Course("课程3",2),new Course("课程4",6),new Course("课程5",3)};int[] score1 = new int[] { 92, 80, 98, 70, 89 };Student s1 = new Student();s1.psno = 1; s1.psname = "王华";s1.setcourse(course1);s1.setscore(score1);s1.computegpa();s1.dispstud();s1.dispgpa();}}}