using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
//判断素数
static bool f(int a)
{
int i;
int count = 0;
for (i = 2; i <=Math.Sqrt(a); i++)
{
if (a % i == 0)
count++;
}
if (count == 0)
return true;
else
return false;
}
//判断水仙花数
static bool shuixianhua(int n)
{
int i = n % 10;
int j = n / 100;
int k = (n % 100) / 10;
if (i * i * i + j * j * j + k * k * k == n)
{
return true;
}else
{
return false;
}
}
int find(int n)
{
int sum = 0;
while (n > 0)
{
if ((n & 1) == 1)
++sum;
n = n >> 1;
}
return sum;
}
//输出101 - 200的素数
void output()
{
int j = 0;
for (j = 101; j <= 200; j++)
{
if (f(j))
{
Console.WriteLine("{0 } ", j);
}
}
}
//输出100 - 999的水仙花数
void outpput()
{
int j;
for (j = 100; j < 1000; j++)
{
if (shuixianhua(j))
{
Console.WriteLine("{0 } ", j);
}
}
}
//将一个正整数分解质因数
void a()
{
int n;
Console.WriteLine("请输入一个整数: ");
n = Convert.ToInt32(Console.ReadLine());
Console.Write(" n = ");
if (f(n))
{
Console.WriteLine("{0}*{1}={2}", 1, n, n);
}
else
{
int i;
for (i = 2; i <= n; i++)
{
if (n % i == 0)
{
Console.Write("{0}*", i);
n = n / i;
}
}
Console.Write("{0}", n);
}
}
//利用条件运算符的嵌套来完成此题: 学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。
void b()
{
int n;
Console.WriteLine("请输入一个整数: ");
n = Convert.ToInt32(Console.ReadLine());
if (n >= 60)
{
if (n >= 90)
{
Console.WriteLine("A");
}
else
{
Console.WriteLine("B");
}
}
else
{
Console.WriteLine("C");
}
}
//求两个数的最大公约数
static int c(int x,int y)
{
if (x > y)
{
int temp;
temp = x;
x = y;
y = temp;
}
if (y % x == 0)
{
return x;
}else
{
return c(y%x,x);
}
}
//输入一行字符串,分别统计出其中英文字母、空格、数字和其它字符的个数
static void calculate()
{
int i = 0;
int zimu = 0;
int kongge = 0;
int shuzi = 0;
int qita = 0;
Console.WriteLine("输入一个字符串:");
string str = Console.ReadLine();
int all = str.Length;
char[] arr = str.ToCharArray();
for (i = 0; i < arr.Length; i++)
{
if (arr[i] >= 'a' && arr[i] <= 'z'|| arr[i] >= 'A' && arr[i] <= 'Z') {
zimu++;
}
else if(arr[i].ToString()==" ")
{
kongge++;
}else if(arr[i]>='0'&& arr[i]<='9')
{
shuzi++;
}else
{
qita++;
}
}
Console.WriteLine("字母:{0} 空格:{1} 数字:{2} 其他:{3} ",zimu,kongge,shuzi,qita);
}
//找完数
static void findwanshu()
{
int i;
int j;
for (i = 1; i <= 1000; i++)
{
int count = 0;
for (j = 1; j <= i / 2;j++ )
{
if (i>=j&&i % j == 0)
{
count += j;
}
}
if (count == i)
{
Console.WriteLine("{0} ",i);
}
}
}
//计算1-1/2+1/3-1/4....-1/10
static void calculate2()
{
int i;
double sum=0;
for (i=1;i<=10;i+=2)
{
sum =sum + (double)1 / (i * (i + 1));
}
Console.WriteLine("和为: {0}", sum);
}
//计算一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
static void calculate3()
{
int i;
double count = 100.00;
for (i = 2; i <= 10; i++)
{
count += count / 2;
}
Console.WriteLine("{0}", count);
}
//计算工资数
static void calculate4()
{
Console.WriteLine("输入利润:");
double su= Convert.ToInt64(Console.ReadLine());
double salary=0;
if (su>=0&&su <= 100000)
{
salary = su * 0.1;
}else if (su>100000&&su<=200000)
{
salary = (su - 100000)*0.075+100000*0.1;
}else if (su > 200000 && su <= 400000)
{
salary = (su - 200000) * 0.05 + 100000 * 0.1+10000*0.075;
}else if (su > 400000 && su <= 600000)
{
salary = (su - 400000) * 0.03 + 100000 * 0.1 + 100000 * 0.075+200000*0.05;
}
else if (su > 600000 && su <= 1000000)
{
salary = (su - 600000) * 0.0015 + 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05+200000*0.03;
}
else if (su > 1000000 )
{
salary = (su - 100000) * 0.01 + 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05+400000*0.015;
}
Console.WriteLine("salary is: {0}",salary);
}
//找到加上100是完全平方数加上268也是完全平方数
static void findit()
{
int i;
int x, y;
for (i = 1; i <= 100000; i++)
{
x = (int )Math.Sqrt(i + 100);
y = (int)Math.Sqrt(i + 268);
if (x * x == (i + 100) && y * y == (i + 268))
{
Console.WriteLine("该数为: {0}",i);
}
}
}
static void Main(string[] args)
{
//Console.WriteLine("enter two number:");
//int a = Convert.ToInt32(Console.ReadLine());
//int b= Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("两个数之间的最大公约数是: {0}", c(a, b));
findit();
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
//判断素数
static bool f(int a)
{
int i;
int count = 0;
for (i = 2; i <=Math.Sqrt(a); i++)
{
if (a % i == 0)
count++;
}
if (count == 0)
return true;
else
return false;
}
//判断水仙花数
static bool shuixianhua(int n)
{
int i = n % 10;
int j = n / 100;
int k = (n % 100) / 10;
if (i * i * i + j * j * j + k * k * k == n)
{
return true;
}else
{
return false;
}
}
int find(int n)
{
int sum = 0;
while (n > 0)
{
if ((n & 1) == 1)
++sum;
n = n >> 1;
}
return sum;
}
//输出101 - 200的素数
void output()
{
int j = 0;
for (j = 101; j <= 200; j++)
{
if (f(j))
{
Console.WriteLine("{0 } ", j);
}
}
}
//输出100 - 999的水仙花数
void outpput()
{
int j;
for (j = 100; j < 1000; j++)
{
if (shuixianhua(j))
{
Console.WriteLine("{0 } ", j);
}
}
}
//将一个正整数分解质因数
void a()
{
int n;
Console.WriteLine("请输入一个整数: ");
n = Convert.ToInt32(Console.ReadLine());
Console.Write(" n = ");
if (f(n))
{
Console.WriteLine("{0}*{1}={2}", 1, n, n);
}
else
{
int i;
for (i = 2; i <= n; i++)
{
if (n % i == 0)
{
Console.Write("{0}*", i);
n = n / i;
}
}
Console.Write("{0}", n);
}
}
//利用条件运算符的嵌套来完成此题: 学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。
void b()
{
int n;
Console.WriteLine("请输入一个整数: ");
n = Convert.ToInt32(Console.ReadLine());
if (n >= 60)
{
if (n >= 90)
{
Console.WriteLine("A");
}
else
{
Console.WriteLine("B");
}
}
else
{
Console.WriteLine("C");
}
}
//求两个数的最大公约数
static int c(int x,int y)
{
if (x > y)
{
int temp;
temp = x;
x = y;
y = temp;
}
if (y % x == 0)
{
return x;
}else
{
return c(y%x,x);
}
}
//输入一行字符串,分别统计出其中英文字母、空格、数字和其它字符的个数
static void calculate()
{
int i = 0;
int zimu = 0;
int kongge = 0;
int shuzi = 0;
int qita = 0;
Console.WriteLine("输入一个字符串:");
string str = Console.ReadLine();
int all = str.Length;
char[] arr = str.ToCharArray();
for (i = 0; i < arr.Length; i++)
{
if (arr[i] >= 'a' && arr[i] <= 'z'|| arr[i] >= 'A' && arr[i] <= 'Z') {
zimu++;
}
else if(arr[i].ToString()==" ")
{
kongge++;
}else if(arr[i]>='0'&& arr[i]<='9')
{
shuzi++;
}else
{
qita++;
}
}
Console.WriteLine("字母:{0} 空格:{1} 数字:{2} 其他:{3} ",zimu,kongge,shuzi,qita);
}
//找完数
static void findwanshu()
{
int i;
int j;
for (i = 1; i <= 1000; i++)
{
int count = 0;
for (j = 1; j <= i / 2;j++ )
{
if (i>=j&&i % j == 0)
{
count += j;
}
}
if (count == i)
{
Console.WriteLine("{0} ",i);
}
}
}
//计算1-1/2+1/3-1/4....-1/10
static void calculate2()
{
int i;
double sum=0;
for (i=1;i<=10;i+=2)
{
sum =sum + (double)1 / (i * (i + 1));
}
Console.WriteLine("和为: {0}", sum);
}
//计算一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
static void calculate3()
{
int i;
double count = 100.00;
for (i = 2; i <= 10; i++)
{
count += count / 2;
}
Console.WriteLine("{0}", count);
}
//计算工资数
static void calculate4()
{
Console.WriteLine("输入利润:");
double su= Convert.ToInt64(Console.ReadLine());
double salary=0;
if (su>=0&&su <= 100000)
{
salary = su * 0.1;
}else if (su>100000&&su<=200000)
{
salary = (su - 100000)*0.075+100000*0.1;
}else if (su > 200000 && su <= 400000)
{
salary = (su - 200000) * 0.05 + 100000 * 0.1+10000*0.075;
}else if (su > 400000 && su <= 600000)
{
salary = (su - 400000) * 0.03 + 100000 * 0.1 + 100000 * 0.075+200000*0.05;
}
else if (su > 600000 && su <= 1000000)
{
salary = (su - 600000) * 0.0015 + 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05+200000*0.03;
}
else if (su > 1000000 )
{
salary = (su - 100000) * 0.01 + 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05+400000*0.015;
}
Console.WriteLine("salary is: {0}",salary);
}
//找到加上100是完全平方数加上268也是完全平方数
static void findit()
{
int i;
int x, y;
for (i = 1; i <= 100000; i++)
{
x = (int )Math.Sqrt(i + 100);
y = (int)Math.Sqrt(i + 268);
if (x * x == (i + 100) && y * y == (i + 268))
{
Console.WriteLine("该数为: {0}",i);
}
}
}
static void Main(string[] args)
{
//Console.WriteLine("enter two number:");
//int a = Convert.ToInt32(Console.ReadLine());
//int b= Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("两个数之间的最大公约数是: {0}", c(a, b));
findit();
Console.ReadKey();
}
}
}