public class Hero
{
//字段
public string name;
private int age;
//属性
public int Age{
get {
return age;
}
set {
age = value;
}
}
public void Bubble(int[] array){
for (int i = 0; i < array.Length - 1; i++) {
for (int j = 0; j < array.Length - i - 1; j++) {
if (array [j] > array[j + 1]) {
int temp = array [j];
array [j] = array [j + 1];
array [j + 1] = temp;
}
}
}
foreach (int a in array) {
Console.Write("{0} ",a);
}
}
public void Swap(ref int a,ref int b){
int temp = a; //a,b依旧是值
a = b;b = temp;
}
public int Cal(int a,int b,out int x,out int y){
x = a + b;
y = a - b;
return x * y;
}
public float Avg(params int[] array){
float sum = 0;
foreach (int a in array) {
sum += a;
}
return sum/array.Length ;
}
public void Change(ref int a, ref int b,ref int c){
int min = (a < b ? a : b) < c ? (a < b ? a : b) : c;
int max = (a > b ? a : b) > c ? (a > b ? a : b) : c;
int mid = a + b + c - max - min;
a = min;b = mid;c = max;
Console.Write ("{0} {1} {2}",a,b,c);
Console.WriteLine ();
}
public int Fire(params int[] array){
int sum = 0;
for (int i = 0; i < array.Length ; i++) {
if (i / 2!= 0) {
array [i] = -array [i];
}
sum+=array[i];
}
return sum;
}
}
{
//字段
public string name;
private int age;
//属性
public int Age{
get {
return age;
}
set {
age = value;
}
}
public void Bubble(int[] array){
for (int i = 0; i < array.Length - 1; i++) {
for (int j = 0; j < array.Length - i - 1; j++) {
if (array [j] > array[j + 1]) {
int temp = array [j];
array [j] = array [j + 1];
array [j + 1] = temp;
}
}
}
foreach (int a in array) {
Console.Write("{0} ",a);
}
}
public void Swap(ref int a,ref int b){
int temp = a; //a,b依旧是值
a = b;b = temp;
}
public int Cal(int a,int b,out int x,out int y){
x = a + b;
y = a - b;
return x * y;
}
public float Avg(params int[] array){
float sum = 0;
foreach (int a in array) {
sum += a;
}
return sum/array.Length ;
}
public void Change(ref int a, ref int b,ref int c){
int min = (a < b ? a : b) < c ? (a < b ? a : b) : c;
int max = (a > b ? a : b) > c ? (a > b ? a : b) : c;
int mid = a + b + c - max - min;
a = min;b = mid;c = max;
Console.Write ("{0} {1} {2}",a,b,c);
Console.WriteLine ();
}
public int Fire(params int[] array){
int sum = 0;
for (int i = 0; i < array.Length ; i++) {
if (i / 2!= 0) {
array [i] = -array [i];
}
sum+=array[i];
}
return sum;
}
}