2020-11-30

//有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和;
using System;
namespace Program
{
    
    public class QiuHe
    {
        public static void FirstTest()
        {
            double a = 1;
            double b = 1;
            double fraction = a/b;
            double Sn = 0;
            for(int i=0;i<20;i++{

                double t1 = a;
                double t2 = b;

                a = t1+t2;

                b = t1;

                fraction = a/b;

                Sn += fraction;

            }
            Console.WriteLine(Sn);
        }

    }
}

 //编写一个应用程序,接受用户输入的一行字符串,判断该字符串是否是回文数?
using System;
namespace Program1
{
    public class ShuRu
    {
        public static void Test()
        {
            string s = "";
            int a = 0;
            Console.WriteLine("请输入一个字符串");
            s = Console.ReadLine();
            char[] b = s.ToCharArray();
            for(int i=0;i<b.Length/2;i++){
                if(b[i]!=b[s.Length-i-1]){
                    a = 1;
                }
            }
            if(a==1){
                Console.WriteLine("该字符串不是回文字符串");
            } else {
                Console.WriteLine("该字符串是回文字符串");
            }
        }

    }
}

namespace Program2
{
    class Program
    {
        static void Main(string[] args)
        {
            Test2.Test();
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值