当前位置: 首页 > 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.yayakq.cn/news/502681/

相关文章:

  • 男女做暖网站wordpress怎么修改logo尺寸
  • 中交上航建设网站网站怎么显示备案号
  • 怎么制作游戏appseo网站优化经理
  • 网站建设宁波力洋深圳做网站公司
  • 免费公网网站建设rest api wordpress
  • 电子政务网站建设的挑战线上培训机构
  • 大屏手机网站wordpress主题有后台
  • 哈尔滨专业网站制作自动发卡网站建设
  • 最好玩的网站建设一个电影网站怎么做
  • 京东pc网站用什么做的我的个人网站 的网页设计
  • php做网站后台世界互联网乌镇峰会
  • 网站怎么上传模板上海设计网站大全
  • 电子商务网站开发技术高邮建设局网站
  • wordpress单屏模板seo系统教程
  • 教育类门户网站网络开发需要学什么
  • 保定建网站需要多少钱h5效果展示网站
  • 如何自己学做网站网站建设 利润
  • 网站备案号和查询的不一样建设返利网站
  • 做美篇发网站建设网站的公司的官网
  • 网站总体策划的内容有哪些网站存在风险怎么解决
  • 德州做名片的网站网站注册
  • 大学网站策划方案邢台抖音优化
  • 上海行业门户网站建设工具现在可以去贵阳吗
  • 按月网站建设wordpress数据库太大
  • 河南省路桥建设集团网站网站建设yuanmus
  • 郑州网站建设居易国际免费空间试用
  • 阿里巴巴国际站入驻费用宿迁建设局网站a类证查询
  • 网页设计图片大小代码seo营销外包公司
  • 个人网站设计怎么做网站的登录注册页面怎么做的
  • wordpress视屏站做啥网站最挣钱