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

网站建设业务的延伸性中国电信网站备案 锁定

网站建设业务的延伸性,中国电信网站备案 锁定,wordpress导航代码,网站开发需要多少钱怎样判断质数问题 输⼊⼀个正整数&#xff0c;判断该数是否是质数。如果为质数输出 yes&#xff0c;如果不是输出no 样例输⼊113 输出yes int n Convert.ToInt32(Console.ReadLine()); int count 0; for (int i 1; i < n 1; i) {if (n % i 0) // 判断该数能被整除{coun…

 判断质数问题

输⼊⼀个正整数,判断该数是否是质数。如果为质数输出 yes,如果不是输出no

样例输⼊113 输出yes

int n = Convert.ToInt32(Console.ReadLine());
int count = 0;
for (int i = 1; i < n + 1; i++)
{if (n % i == 0) //  判断该数能被整除{count++; // 计数器+1}
}
if (count == 2) // 次数为2代表1和它本身,即为质数
{Console.WriteLine("yes");
}
else
{Console.WriteLine("no");
}

输出因数问题

输⼊⼀个整数,输出该整数的因数个数和所有因数。
样例输⼊ 9 样例输出 3  1  3  9

int n = Convert.ToInt32(Console.ReadLine());
int count = 0;
string a = ""; // 定义空字符串变量,为了后面存储所有因数
for (int i = 1; i < n + 1; i++)
{if (n % i == 0) // 因数就是能被整除的数{count++;  // 次数+1a += i + " "; // 因数存储}
}
Console.WriteLine(count); // 输出因数个数
Console.Write(a); // 输出所有的因数

整数插入有序数组组成新的有序数组:

有n(n<=100)个整数,已经按照从⼩到⼤顺序排列好,现在另外给⼀个整数x,请将该数插⼊到序列中,并使新的序列仍然有序。输出新的序列。

样例输入:10 20 30 40 50        15   样例输出:10 15 20 30 40 50

class Program{static void Main(string[] args){string str = Console.ReadLine();// 输入有序数组// 将字符数组转换为整数数组string[] strArray = str.Split(' ');int[] intArray = new int[strArray.Length];for (int i = 0; i < strArray.Length; i++){int num = Convert.ToInt32(strArray[i]);intArray[i] = num; // 赋值}// 给的整数xint x = Convert.ToInt32(Console.ReadLine());int nIndex = intArray.Length - 1;// 假设索引是最后一位for (int i = 0; i < intArray.Length - 1; i++){if (x >= intArray[i] && x <= intArray[i + 1]) // 找出该整数的索引{nIndex = i;break;}}if (x < intArray[0]) // 特殊情况,该整数为最小值时{nIndex = -1;}int[] intNewArray = new int[intArray.Length + 1]; // 定义新数组// 0-nIndex = 0 - -1for (int i = 0; i < nIndex + 1; i++){intNewArray[i] = intArray[i]; // 遍历到nIndex + 1给新数组赋值}intNewArray[nIndex + 1] = x; // 将该整数也放入新数组中// nIndex+1 -- length-1for (int i = nIndex + 1; i < intArray.Length; i++){intNewArray[i + 1] = intArray[i];  // 从nIndex + 1开始继续遍历给新数组赋剩余的值}foreach (int num in intNewArray){Console.Write(num + " ");// 输出新的有序数组}}}

http://www.yayakq.cn/news/249833/

相关文章:

  • 一家做运动鞋的网站好区网站制作
  • 建设工程信息服务平台新网站html转化wordpress
  • 给用ps做的网站加div学用php做网站
  • 网站主持人网站空间商盗取数据
  • 网站建设咨询哪家性价比高天元建设集团有限公司鲁班奖
  • 用jsp做的二手交易网站广东省建设厅人才网站
  • 一级a做爰片免费网站 小说阿里云网站备案查询
  • 企业网站优化电话我想做社区团购怎么做
  • 网站建设公司软jian湖南岚鸿在本地怎么做网站
  • 网站建设五行做网站制作一般多少钱
  • 汕头网站定制深圳高端别墅设计公司
  • 17网站一起做网店东莞有没有帮忙做问卷调查的网站
  • 淘宝客cms网站模板下载购物网站开发的业务需求分析
  • 荆州市住房和城乡建设厅官方网站wordpress audaz主题
  • 乐山住房和规划建设局门户网站多站点cms
  • 没有虚拟主机怎么建网站网站维护和建设工作范围
  • 营销网站参考wordpress获取根目录路径
  • 网站建设英语怎么说西宁建设网站
  • 企业网站对企业有什么好处瑞华特散热器网站谁给做的
  • 网站建设学生作业成品网站集约化建设工作总结
  • dede做网站响应式网站div居中
  • 二手车网站策划wordpress上传小视频教程
  • 网站建设升级ui设计教学
  • 深圳网站建设公司服务wordpress返回上一页插件
  • 国外免费网站空间网页 网站及与之相关的概念
  • 环保业网站建设的策划wordpress 主题目录注册
  • 建设旅游网站系统开发公司租赁房产
  • 龙岩建设网站上海优化营商环境
  • 音乐网站建设教程太平洋保险网站
  • 直播的网站开发网站开发需求问卷