📄 8-2.txt
字号:
using System;
class Student
{
public string s_name;
public int s_age;
public float s_weight;
public Student(string n, int a, float w) {
s_name = n;
s_age = a;
s_weight = w;
}
public int max_age(int x, int y) {
if ( x>y ) return x;
else return y;
}
public float max_weight( float x, float y) {
if( x>y ) return x;
else return y;
}
}
class Test
{
public static void Main() {
Student s1 = new Student( "Mike",20,80);
Student s2 = new Student( "John",21,70);
if(s1.max_age(s1.s_age,s2.s_age)==s1.s_age)
Console.WriteLine("{0}'s age is bigger than {1}'s",s1.s_name,s2.s_name);
else
Console.WriteLine("{0}'s age is smaller than {1}'s",s1.s_name,s2.s_name);
if(s1.max_weight(s1.s_weight,s2.s_weight)==s1.s_weight)
Console.WriteLine("{0}'s weight is bigger than {1}'s",s1.s_name,s2.s_name);
else
Console.WriteLine("{0}'s weight is smaller than {1}'s",s1.s_name,s2.s_name);
}
}
//----------------------------------------------------------------------------------------------------------------------------------------------
using System;
class Student
{
public string s_name;
public int s_age;
public float s_weight;
public Student(string n, int a, float w) {
s_name = n;
s_age = a;
s_weight = w;
}
public int max(int x, int y) {
if ( x>y ) return x;
else return y;
}
public float max( float x, float y) {
if( x>y ) return x;
else return y;
}
}
class Test
{
public static void Main() {
Student s1 = new Student( "Mike",20,80);
Student s2 = new Student( "John",21,70);
if(s1.max(s1.s_age,s2.s_age)==s1.s_age)
Console.WriteLine("{0}'s age is bigger than {1}'s",s1.s_name,s2.s_name);
else
Console.WriteLine("{0}'s age is smaller than {1}'s",s1.s_name,s2.s_name);
if(s1.max(s1.s_weight,s2.s_weight)==s1.s_weight)
Console.WriteLine("{0}'s weight is bigger than {1}'s",s1.s_name,s2.s_name);
else
Console.WriteLine("{0}'s weight is smaller than {1}'s",s1.s_name,s2.s_name);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -