if (c<b)
n=a+b+c;
else if (a+b<c)
n=c-a-b;
else
簡答5在C#中如何定義常量?常量的定義是否一定包含初始化?為什么?
using System;
class Test
{
static void main
int k;
Console.Write("請輸入整數(shù)k的值:");
k=int.Parse(Console.ReadLine( ));
if (k<=10 )
k=k+1;
else if (10<k<=20)
k-=10;
else if(k>30)
k=k*2-20;
Console.WriteLine("k={0} ", k)
}
class ARRAY
public static void Main( )
int oddsum=0;
int evensum=0;
int[ ] arr={0,1,2,5,7,8,12,13};
foreach (int k in arr)
if (k%2= =0)
evensum+=k;
oddsum+=k;
Console.WriteLine("evensum={0} ",evensum);
Console.WriteLine("oddsum={0} ",oddsum);
public class array1
int[] a={34,91,83,56,29,93,56,12,88,72};
int i,t=0,temp=100;
for (i=0;i<a.Length;i++)
if (a[i] <= temp)
temp=a[i];
t=i;
Console.WriteLine("該數(shù)組中最小的數(shù)為:{0} ", temp);
Console.WriteLine("最小的數(shù)的數(shù)組下標(biāo)為:{0} ",t);
static void Main( )
M( );
int M( )
Console.WriteLine("Welcome")
class MyClass
private int x;
public MyClass(int x)
x=x;
private void SetX(int a)
x=a;
MyClass m=new MyClass(18);
SetX(68);
編寫一個程序,分別用for、while、do…while語句求前n個自然數(shù)的和。
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81
已知5個考生6門課程成績
課1 課2 課3 課4 課5 課·6
考生1 61 62 63 64 65 66
考生2 72 73 74 75 76 77
考生3 83 84 85 86 87 88
考生4 94 95 96 97 98 99
考生5 64 65 66 77 88 99
請定義一個二維數(shù)組,存儲并計算這5個考生的平均成績。