当前位置: 首页 > news >正文

网站开发运营苏州网站建设公司

网站开发运营,苏州网站建设公司,游戏网站模,双城网站26.寻找并输出11至999之间的数m,它满足m,m2和m3均为回文数。所谓回文数是指其各位数字左右对称的整数,例如121,676,94249等。满足上述条件的数如m11,m2121,m31331皆为回文数。请编制函数实现此功能,如果是回文数&#…

26.寻找并输出11至999之间的数m,它满足m,m2和m3均为回文数。所谓回文数是指其各位数字左右对称的整数,例如121,676,94249等。满足上述条件的数如m=11,m2=121,m3=1331皆为回文数。请编制函数实现此功能,如果是回文数,则函数返回1,反之则返回0。最后把结果输出。

27.键盘上任意输入一个十进制整数,请编制函数,将该整数转换成二进制数并把已转换的二进制数存放在字符串数组x中,最后调用函数把结果输出。

28.用键盘输入一个16进制数,并将该16进制数转换为二进制输出。

29.设有n个人围坐一圈并按顺时针方向从1到n编号,从第s个人开始进行1到m的报数,报数到第个m人,此人出圈,再从他的下一个人重新开始1到m的报数,如此进行下去直到所有的人都出圈为止。现要求按出圈次序,每10人一组,输出这n个人的顺序表在控制台。

30.读取一篇英文文章存入到字符串数组x中,请编制函数,其功能是:以行为单位对行中以空格或标点符号为分隔的所有单词进行倒排。最后把已处理的字符串(应不含标点符号)仍按行重新存入字符串数组x中,最后调用函数把结果x输出。

例如:原文:  You ,He, Me。 I  am  a  student。

   结果:Me He You                student a am I

26、首先定义一个函数是否是回文代码如下:

27、我们要定义一个转换的方法,代码如下:

private static void Main(string[] args)
{
    Console.WriteLine("请输入一个十进制整数:");
    int s = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine("二进制结果是:"+ DecimalToBinary(s));
}
public static string DecimalToBinary(int decimalNumber)
{
    return Convert.ToString(decimalNumber, 2);
}

28代码如下:

Console.WriteLine("请输入16进制是: ");
string hexNumber = Console.ReadLine();
byte[] hexBytes = new byte[hexNumber.Length / 2];

for (int i = 0; i < hexBytes.Length; i++)
{
    int index = i * 2;
    hexBytes[i] = Convert.ToByte(hexNumber.Substring(index, 2), 16);
}

Console.WriteLine("16进制是: " + hexNumber);
Console.WriteLine("二进制结果是: ");

foreach (byte b in hexBytes)
{
    string binaryString = Convert.ToString(b, 2).PadLeft(8, '0');
    Console.WriteLine(binaryString);
}

29、代码如下:

private static void Main(string[] args)
{
    Console.WriteLine("请输入总人数:");

    int n = Convert.ToInt32(Console.ReadLine());  // 总人数
    int s = 1; // 开始报数的位置
    int m = 10; // 报数的间隔
    List<int> people = new List<int>();
    for (int i = 1; i <= n; i++)
    {
        people.Add(i); // 初始化编号
    }
    List<int> result = JosephusProblem(people, s, m);
    foreach (var id in result)
    {
        Console.WriteLine(id); // 输出出圈顺序
    }
}

static List<int> JosephusProblem(List<int> people, int s, int m)
{
    List<int> result = new List<int>(); // 存储出圈顺序的列表
    while (people.Count > 0)
    {
        int index = s - 1; // 计算当前报数的位置(数组索引从0开始)
        index = index % people.Count; // 处理环形结构
        result.Add(people[index]); // 将出圈的人添加到结果列表中
        people.RemoveAt(index); // 从列表中移除该人
        s++; // 下一次报数从下一个人开始
        if (s > people.Count) s = 1; // 如果s超过当前人数,重置s为1
    }
    return result; // 返回出圈顺序的列表
}

30、首先定义一个方法来过滤特殊字符,数组进行倒序排列用到reserve方法,代码如下

private static void Main(string[] args)
{
    string article = "You ,He, Me。 I  am  a  student。";
    string[] words = SplitArticleIntoWords(article);  // 方法
    Array.Reverse(words); // 倒序
    foreach (string word in words)
    {
        Console.Write(word); // 输出
    }
}

static string[] SplitArticleIntoWords(string article)
{
    char[] separators = new char[] { ',', '.', '!', '?', ';', ',' ,'。',' '}; // 过滤特殊字符
    string[] words = article.Split(separators, StringSplitOptions.RemoveEmptyEntries);
    return words;
}

http://www.ds6.com.cn/news/23845.html

相关文章:

  • 做产品网站营销推广百度搜索网
  • 专用车网站建设哪家好做百度推广
  • 太原谁想做网站老鬼seo
  • 天津业之峰装饰公司官网澳门seo推广
  • 设计网站收费google网站推广
  • 本机怎么放自己做的网站百度上搜索关键词如何在首页
  • 哪里可以捡到玉石seo全称
  • 网站优化的基本思想北京今日重大新闻
  • 网站建设的一般流程是正规的培训学校
  • 做网站全屏图片拉长代码南昌网站设计
  • oa办公系统开发百度seo排名软
  • 化工课设代做网站域名注册费用
  • 什么是电子商务网站开发站长域名查询
  • 合肥新格建站网广州seo服务公司
  • 网站咨询弹窗是怎么做的搜索引擎营销的方法包括
  • 可视化的网站开发工具专业网络推广公司排名
  • 连云港企业网站制作怎么建立个人网站
  • 泉州茶叶网站建设seo工具在线访问
  • 什么网站做问卷好世界营销大师排名
  • 专业做设计的网站全网推广外包公司
  • 做一个网站成本是多少合适体验营销策略有哪些
  • 嘉兴做网站优化多少钱南京网站设计公司
  • wordpress中文版源码下载郑州seo优化服务
  • 做网站哪家好公司google推广教程
  • 东莞网站推广渠道抚州seo排名
  • 博山政府网站建设哪家专业网站建设的流程及步骤
  • 做网站公司 蓝纤科技seo小白入门教学
  • 如何做提卡网站如何在网络上推广产品
  • 鞍山建设集团网站合肥seo网站排名
  • 1000元做网站怎样利用互联网进行网络推广