using System;
public class TestNumSort {
public static void Main() {
int a, b, c, d;
for (a = 1; a <= 4; a++)
for (b = 1; b <= 4;b++ ) for (c=1;c <= 4;c++)
if (a != b && a != c && b != c)//abc互不相等 {
d = 10 - a - b - c;
if ((c == 1 ^ b == 2) && (c == 2 ^ d == 3) && (a == 2 ^ d == 4))//甲乙丙都有一半是正确的 {
Console.Write(\红球放置在{0}号,黄球放置在{1}号,\, a, b); Console.WriteLine(\黑球放置在{0}号,白球放置在{1}号,\, c, d);
} }
Console.Read(); } }
using System;
public class TestNumSort {
public static void Main() {
int a=1, b=1, c=1, d; while (a <= 4) {
while (b <= 4) {
while (c <= 4) {
if (a != b)
if ( a != c)
if ( b != c)//abc互不相等 {
d = 10 - a - b - c;
if ((c == 1 && b == 4) && (a == 2 && d == 3))//甲乙丙都有一半是正确的
{
Console.WriteLine(\红球放置在{0}号,黄球放置在{1}号,黑球放置在{2}号,白球放置在{3}号,\, a,b,c, d); } } c++; }
b++; c = 1; }
a++; b = 1; c = 1; }
Console.Read(); } }
using System;
public class TestNumSort {
public static void Main() {
double sum = 0.5, t, t1, t2, t3, p = 0.5 * 0.5; int odd = 1, even = 2; t = t1 = t2 = 1.0; t3 = 0.5; while (t > 1e-10) {
t1 = t1 * odd / even; odd += 2; even += 2; t2 = 1.0 / odd; t3 = t3 * p; t = t1 * t2 * t3;
sum += t; }
Console.WriteLine(\, sum * 6); Console.Read(); } }
using System;
public class TestNumSort {
public static void Main() {
double sum = 0.5, t, t1, t2, t3, p = 0.5 * 0.5; int odd = 1, even = 2; t = t1 = t2 = 1.0; t3 = 0.5; do {
t1 = t1 * odd / even; odd += 2; even += 2; t2 = 1.0 / odd; t3 = t3 * p; t = t1 * t2 * t3; sum += t; }
while (t > 1e-10);
Console.WriteLine(\, sum * 6); Console.Read(); } }
using System;
public class TestNumSort {
public static void Main() {
double sum = 0.5, t, t1, t2, t3, p = 0.5 * 0.5, s; int odd = 1, even = 2;
t = t1 = t2 = 1.0; t3 = 0.5; while (t > 1e-10) {
t1 = t1 * odd / even; odd += 2; even += 2; t2 = 1.0 / odd; t3 = t3 * p; t = t1 * t2 * t3; sum += t; }
Console.Write(\请输入圆的半径:\); string j = Console.ReadLine(); int r = Convert.ToInt32(j);
s = sum * 6 * r * r;
Console.WriteLine(\, sum * 6, sum * 6 * r * r); Console.Read();
} }
using System;
public class Test6174 {
public static void Main()
{
Console.Write(\请输入一个4位整数\); string s = Console.ReadLine(); int num = Convert.ToInt32(s); int[] each = new int[4]; int max, min, i, j, temp;
while (num != 6174 && num != 0) {
i = 0;
while (num != 0) {
each[i++] = num; num = num / 10; }
for (i = 0; i < 3; i++)
for (j = 0; j < 3 - i; j++)
if (each[j] > each[j + 1]) {
temp = each[j];
each[j] = each[j + 1]; each[j + 1] = temp; }
min = each[0] * 1000 + each[1] * 100 + each[2] * 10 + each[3]; max = each[3] * 1000 + each[2] * 100 + each[1] * 10 + each[0]; num = max - min;
Console.WriteLine(\, max, min, num); }
Console.Read(); } }
using System;
using System.Collections.Generic; using System.Linq;