一、从键盘上输入10个整数存入数组中,然后将该数组中的各元素按顺序存放后输出结果 int temp = 0; int[] nums = new int[10]; for (int i = 0; i < nu***ength; i++) { Console.WriteLine("请输入整数:"); nums[i] = Convert.ToInt32(Console.ReadLine()); } for (int i = 0; i < nu***ength-1; i++) { for (int j = 0; j < nu***ength-1-i; j++) { if (nums[j+1]<nums[j])//大于号,从大到小排序。小于号,从小到大排序 { temp = nums[j]; nums[j] = nums[j + 1]; nums[j + 1] = temp; } } } for (int i = 0; i < nu***ength; i++) { Console.Write(nums[i]+" "); } Console.ReadKey(); 二、定义一个学生类,满足下列要求:(1)包括学号.姓名.成绩三个属性;(2)构造函数给各个数据成员初始化;(3)输出每个学生信息的成员函数。主函数中测试该学生类,要求键盘输入学生信息来定义对象,并输出该对象信息。 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _05构造函数练习 { class Program { static void Main(string[] args) { Student stuOne = new Student("小明", '男', 194, 90, 90, 80); stuOne.Say(); Console.ReadKey(); } } } 学生类: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _05构造函数练习 { class Student { string _name; public string Name { get { return _name; } } char _sex; public char Sex { get { return _sex; } } int _age=18; public int Age { get { if (_age > 100 || _age < 0) { _age = 18; return _age; } else { return _age; } } } int _chinese=0; public int Chinese { get { return _chinese; } } int _math=0; public int Math { get { return _math; } } int _english=0; public int English { get { return _english; } } //第一个构造函数,里面可以传6个参数 public Student(string name,char sex,int age,int chinese,int math,int english) { this._name = name; this._sex = sex; this._chinese = chinese; this._math = math; this._english = english; } public void Say() { Console.WriteLine("我叫{0},今年{1}岁了,是{2}同学,语文成绩:{3},数学成绩:{4},英语成绩:{5}",_name,Age,_sex,_chinese,_math,_english); } } }