ACCP7.0S2深入.NET和C#编程第二章上机1,2

-------上机1

class 上机1
    {
        static void Main(string[] args)
        {
            int[] oldpoint = new int[5];
            int[] newpoint=new int[5];
            Console.WriteLine("请输入五位会员积分");
            for (int i = 0; i < oldpoint.Length;i++)
            {
                Console.WriteLine("第" + (i + 1) + "位会员积分为:");
                oldpoint[i] = Convert.ToInt32(Console.ReadLine());
            }
            for (int i = 0; i < newpoint.Length; i++)
            {
                newpoint[i] = oldpoint[i] + 500;
            }
            Console.WriteLine("序号\t历史积分\t新年积分");
            for (int i = 0; i < newpoint.Length; i++)
            {
                Console.Write((i+1)+"\t"+oldpoint[i]+"\t");
                Console.WriteLine("\t"+newpoint[i]);
            }
            Console.WriteLine("按任意键继续");
            Console.ReadLine();
        }
    }
------上机2

class Program
    {
        static void Main(string[] args)
        {
            computer computer = new computer();
            computer[] com = new computer[3];
            com[0] = new computer();
            com[0].type = "hpCQ-217TX";
            com[0].date = "2013-10-5";
            com[1] = new computer();
            com[1].type = "Mc240CH/A";
            com[1].date = "2013-10-5";
            com[2] = new computer();
            com[2].type = "SYNW18H/W";
            com[2].date = "2013-10-5";
            Console.WriteLine("===========设置计算机id前===========");
            Console.WriteLine("计算机型号\t计算机id\t购买时间");
            for (int i = 0; i < com.Length; i++)
            {
                Console.WriteLine(com[i].type + "\t\t\t" + com[i].date);
            }
            Random ran = new Random();
            com[0].num = ran.Next(1000, 9999);
            com[1].num = ran.Next(1000, 9999);
            com[2].num = ran.Next(1000, 9999);
            Console.WriteLine("===========设置计算机id后===========");
            Console.WriteLine("计算机型号\t计算机id\t购买时间");
            for (int i = 0; i < com.Length; i++)
            {
                Console.WriteLine(com[i].type + "\t" +com[i].type+"-"+ com[i].num + "\t" + com[i].date);
            }
            Console.ReadLine();
        }
        public class computer
        {
            public string type;
            public int num;
            public string date;
        }
    }



  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值