魔方吧·中文魔方俱乐部

 找回密码
 注册
搜索
热搜: 魔方
楼主: qiaoyisi
打印 上一主题 下一主题

有趣的数论问题 [复制链接]

Rank: 2

积分
523
帖子
251
精华
1
UID
40010
性别
保密
21#
发表于 2014-1-6 12:42:39 |只看该作者
谢谢把程序发上来看看。

使用道具 举报

Rank: 4

积分
1206
帖子
1153
精华
0
UID
82168
性别
保密
居住地
其他
兴趣爱好
破解
理论
其它

八年元老 十年元老

22#
发表于 2014-1-6 13:37:19 |只看该作者
qiaoyisi 发表于 2014-1-6 12:42
谢谢把程序发上来看看。

1到12的程序
实在没啥值得一提的..
不知不觉这个号就申了四年多了吖..关键是还有密码登..
赶脚还有另一个号..也不造是哪个新点..

一眨眼都八年多了....

使用道具 举报

Rank: 2

积分
523
帖子
251
精华
1
UID
40010
性别
保密
23#
发表于 2014-1-6 14:31:17 |只看该作者
好的,谢谢!

使用道具 举报

Rank: 4

积分
1206
帖子
1153
精华
0
UID
82168
性别
保密
居住地
其他
兴趣爱好
破解
理论
其它

八年元老 十年元老

24#
发表于 2014-1-6 14:35:17 |只看该作者
qiaoyisi 发表于 2014-1-6 14:31
好的,谢谢!

你的程序不是大概这样的么..
不知不觉这个号就申了四年多了吖..关键是还有密码登..
赶脚还有另一个号..也不造是哪个新点..

一眨眼都八年多了....

使用道具 举报

Rank: 2

积分
523
帖子
251
精华
1
UID
40010
性别
保密
25#
发表于 2014-1-6 15:03:28 |只看该作者
我给你发消息留言了

使用道具 举报

Rank: 2

积分
523
帖子
251
精华
1
UID
40010
性别
保密
26#
发表于 2014-1-16 12:01:47 |只看该作者
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Pai
{
    public partial class FormSort : Form
    {
        List<List<int>> lli = new List<List<int>>();
        public FormSort()
        {
            InitializeComponent();
        }

        private void FormSort_Load(object sender, EventArgs e)
        {
            lbMsg.Text = "";
            tCount.Enabled = false;
            bResult.Enabled = false;
        }

        private void bCalculate_Click(object sender, EventArgs e)
        {
            lli.Clear();

            lbMsg.Text = "";
            tResult.Clear();
            bResult.Enabled = false;
            tCount.Enabled = false;

            List<int> d = new List<int>();
            int len;
            int i = 0;

            try
            {
                if (string.IsNullOrEmpty(tNum.Text))
                {
                    MessageBox.Show("请输入数组。");
                    return;
                }

                string[] arrStr = tNum.Text.Split(',');
                foreach (string str in arrStr)
                {
                    int num = Convert.ToInt32(str);

                    if (d.Count == 0)
                        d.Add(num);
                    else
                    {
                        if (num < d[0])
                            d.Insert(0, num);
                        else if (num > d[d.Count - 1])
                            d.Add(num);
                        else
                        {
                            for (i = 0; i < d.Count - 1; i++)
                            {
                                if (num > d[i] && num < d[i + 1])
                                {
                                    d.Insert(i + 1, num);
                                    break;
                                }
                            }
                        }
                    }
                }
                len = d.Count;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            List<int> tmp = new List<int>();
            List<int> t = new List<int>();

            for (i = 0; i < len; i++)
            {
                tmp.Add(0);
                t.Add(d[i]);
            }

            int strCount = 0;
            while (t.Count == d.Count)
            {
                bool bFound = false;

                if (t.Count > 1)
                {
                    for (i = 0; i < t.Count - 1; i++)
                    {
                        if (t[i] == 0 && Math.Abs(t[i + 1]) > 1 || t[i + 1] == 0 && Math.Abs(t[i]) > 1)
                        {
                            bFound = true;
                            break;
                        }
                        else if (t[i] - t[i + 1] < -1 || t[i] - t[i + 1] > 1)
                        {
                            if (gcd(t[i], t[i + 1]) > 1)
                            {
                                bFound = true;
                                break;
                            }
                        }
                    }
                }

                if (!bFound)
                {
                    //lli.Add(t);
                    strCount++;

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

Archiver|手机版|魔方吧·中文魔方俱乐部

GMT+8, 2024-4-26 04:01

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部