using System;
using System.Collections;
class Sum_Average
{
public static void Main()
{
int sum=0;
float average=0.0f;
Random r=new Random ();
ArrayList myArrayList=new ArrayList ();
Console.WriteLine ("你想算几个数的和,并求它的平均值:");
int iMax=int.Parse (Console.ReadLine ());
for(int i=0;i<iMax;i++)
{
myArrayList.Add (r.Next (0,100));
}
Console.WriteLine ("这{0}个数是:",iMax);
foreach(int pins in myArrayList)
{
Console.WriteLine (pins);
}
for(int j=0;j<iMax;j++)
{
sum+=(int)myArrayList[j];
}
Console.WriteLine ("这{0}个数的和是:{1}",iMax,sum);
average = (float)sum / iMax;
Console.WriteLine ("这{0}个数的平均值是:{1}",iMax,average);
}
}
using System;
public class book_ticket
{
public static void Main()
{
int[] A=new int[10];
int next;
Console.WriteLine ("欢迎使用南方航空公司预订票系统:");
Console.WriteLine ("1预订头等仓:");
Console.WriteLine ("2预订经济仓:");
Console.WriteLine ("-1退出:");
do
{
Console.WriteLine ("请选择:");
next=int.Parse (Console.ReadLine ());
switch(next)
{
case 1:
Console.WriteLine ("请输入座位号:(1-5)");
int next1=int.Parse (Console.ReadLine ());
if(A[next1-1]==1)
Console.WriteLine ("抱歉...该座位{0}已被订.",next1);
else
A[next1-1]=1;
Console.WriteLine ("座位{0}预订成功.欢迎下次再来!",next1);
break;
case 2:
Console.WriteLine ("请输入座位号:(6-10)");
int next2=int.Parse (Console.ReadLine ());
if(A[next2-1]==1)
Console.WriteLine ("抱歉...该座位{0}已被订.",next2);
else
A[next2-1]=1;
Console.WriteLine ("座位{0}预订成功.欢迎下次再来!",next2);
break;
case -1:
break;
default:
return;
}
}while(next!=-1);
}
}