水仙花数100以内素数判断素数水仙花数100以内素数判断素数
水仙花数
using System;
using System.Collections.Generic; using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
class Program
{
static void Main(string[] args)
{
int a; int b, c, d;
for (a = 100; a = a) //判断
{
Console.Write(" ...
水仙花数100以内素数判断素数
水仙花数
using System;
using System.Collections.Generic; using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
class Program
{
static void Main(string[] args)
{
int a; int b, c, d;
for (a = 100; a < 1000; a++)
{
b = a / 100;
c = a / 10 % 10;
d = a %10;
if (a == b * b * b + c * c * c + d * d * d)
Console.WriteLine(a);
}
}
}
}
100以内的素数
using System;
using System.Collections.Generic; using System.Linq;
using System.Text;
namespace ConsoleApplication3 {
class Program
{
static void Main(string[] args)
{
int a, i,n=0;//n为计数器
for (a = 3; a <= 100; a++)//100以内
{
for (i = 2; i < a; i++)
{
if (a % i == 0)//判断
break;
}
if (i >= a) //判断
{
Console.Write(" " + a);//输出
n++;//累加
if (n % 4 == 0)//每行4个
Console.WriteLine();
}
}
}
}
}
判断素数
using System;
using System.Collections.Generic; using System.Linq;
using System.Text;
namespace ConsoleApplication6 {
class Program
{
static void Main(string[] args)
{int a, i;
double b;
Console.WriteLine("请输入一个数值:");
a = Convert.ToInt32(Console.ReadLine());
b = a / 2;
for (i = 2; i <= b; i++)
{
if (a % i== 0)
{
break;
}
}
if(i>b)
{ Console.WriteLine("是素数");
}
else
{
Console.WriteLine("不是素数");
}
}
}
}
本文档为【水仙花数100以内素数判断素数】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。