c#实现3和4的公倍数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace test1
{
class Program
{
static void Main(string[] args)
{
int n;
string s;
Console.WriteLine("请输入一个数:");
s=Console.ReadLine(); n = int.Parse(s);
if (n % 4 == 0 && n % 3 == 0) Console.WriteLine("该函数能同时被3和4整除"); else
Console.WriteLine("该函数不能同时被3和4整除");
}
}
}
题目二:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2 {
class Program
{
static void Main(string[] args)
{
string s;
int a, b, c, d;
Console.WriteLine("请输入一个三位正整数"); s = Console.ReadLine(); a = int.Parse(s);
b = a/100;
c = (a - b * 100) / 10;
d = (a - b * 100 - 10 * c); Console.WriteLine("{0}{1}{2}",d ,c,b);
}
}
}
2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
string s;
int a;
s=Console.ReadLine();
a = int.Parse(s);
if (a % 3 == 0 && a % 4 == 0)
Console.Write("能被整除");
else
Console.WriteLine("不能被整除");
}
}
}
2、编程将用户输入的一个三位正整数逆序输出。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
string s;
int a, b, c, d;
Console.WriteLine("请输入一个三位数");
s = Console.ReadLine();
a = int.Parse(s);
b = a % 10;
c = ((a - b) % 100) / 10;
d = (a - b - (a - b) % 100) / 100;
Console.WriteLine("{0}{1}{2}", b, c, d);
}
}
}
3
2、编程将用户输入的一个三位正整数逆序输出。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ex4
{
class Program
{
static void Main(string[] args)
{
string s;
uint a, b, c, t, h;
Console.WriteLine("请输入一个三位正整数:");
s = Console.ReadLine();
t = uint.Parse(s);
a = t % 10;
c = t / 100;
b = (t - c * 100) / 10;
h = a * 100 + b * 10 + c;
if (a != 0)
Console.WriteLine("逆序后的数为:{0}", h);
else
Console.WriteLine("逆序后的数为:0{0}", h);
}
}
}