C#学习日记——实验1

It feels like nobody ever know me till you know me

Feels like nobody ever loved me till you loved me

Feels like nobody ever touched me till you touched me

Baby,nobody,nobody,nobody,nobody,until you

--Shayne Ward《Until You》

Experiment_1:

【描述】熟悉VS2010开发环境,熟悉各个窗口。

略。

Experiment_2:

【描述】一数列的规则如下:1,1,2,3,5,8,13,21,34......求第30位数是多少?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Experiment_1_01
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("The number is :");
            
            int a = 1, b = 1, c=0;
            for(int i=3;i<31;i++){
                c=a+b;
                a = b;
                b = c;
            }
            Console.WriteLine(c);
            
            
        }
    }
}

Experiment_3:

【描述】输入一个年份,判断是否为闰年(被4整除,且不被100整除,或者被400整除)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Experiment_1_02
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please input your year:");
            string s=Console.ReadLine();
            int y = int.Parse(s);
            if (y % 4 == 0 || y % 400 == 0 && y % 100 != 0)
                Console.WriteLine("{0}is LeapYear", y);
            else
                Console.WriteLine("{0}is not LeapYear", y);
        }
    }
}

Experiment_4:

【描述】一青年歌手参加比赛,有10位评委打分,(分值只能为正整数数字),计算并输出歌手的平均分(去掉一个组高分和一个最低分)。平均分以double数据类型输出。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Experiment_1_03
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please input your ten numbers:");
            string[] a = Console.ReadLine().Split(' ');
            int sum=0;
            int max=-10,min=1000;
            for(int i=0;i<10;i++){
                int b=int.Parse(a[i]);
                if (max < b)
                {
                    max = b;
                }
                if (min > b)
                {
                    min = b;
                }
                sum += b;
            }
            double average;
            average=(sum-max-min)/8.0;            //please pay your attention
            Console.WriteLine(average);
        }
    }
}

Experiment_5:

【描述】输入一个字符串,判断该字符串是否为“回文”(即顺读和逆读相同的字符串)。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Experiment_1_04
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please input your arrays:");
            string s = Console.ReadLine();
            char[] c = s.ToCharArray();
            bool f = true;
            for(int i=0,j=c.Length-1;i<c.Length;i++,j--){
                if(i==j||j<i){
					 break;
				}
                   
                if(c[i]!=c[j]){
                    f=false;
                    break;
                }
            }
            if(f)
                Console.WriteLine(s+"是回文字符串");
            else
                Console.WriteLine(s+"不是回文字符串");
        }
    }
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值