|
[与主题无关,锁帖]保密你的隐私
更重要的是这个软件可以根据自己需要定制,强!!! |
|
|
|
[与主题无关,锁帖]保密你的隐私
好象有一个软件可以,但是也很麻烦! index.dat在windows下是删不掉的,删了反而会有麻烦! 最好在安装新机时,备份一份,在还没有进入windows时替换掉它! |
|
求m个数中的n个数的和(m≥n>0)的所有解[求助]
Sub add2(a() As Double, m As Long, n As Long, b() As Double) '求a(m)~a(n)中任意两个数的和 'b()为两个数的和 Dim k As Long Dim i As Long Dim k1 As Long k1 = UBound(a) ReDim b((1 + n - m) * (n - m) / 2 - 1) '重新分配空间 Do For i = m + 1 To n b(k) = a(m) + a(i) k = k + 1 Print a(m) & "+" & a(i) & "=" & b(k - 1), Next m = m + 1 Loop Until m = n End Sub 不知大于2的怎么写??? |
|
有谁可以写出这样的代码
Dim a1,a2,a3...... as Double 这样是很不规范的写法! 其实你这样写只是定义了最后一个变量!!! 没有定义变量,编译后运行的速度会很慢!!! 为的只是增加编译后运行的速度,不定义会很慢的! 不好意思。 前面 Dim i1 as Double.......Dim i29 as Double 应为 Dim i1 as Long .......Dim i29 as Long Double是双精度,为了支持小数。 当然我的方法只是很笨的一个方法,即所有的组合都用上了,效率很低!!! |
|
有谁可以写出这样的代码
可以了,很好的算法! 能否先估等式是由几位数组成,再在这几位里找,这样可能会更快? 比如:1 2 3 4 5 total=6 6>5 所以至少有两个数组成 6=1+2+3 所以三位数只有一种,其他只需在两个数里找。 |
|
有谁可以写出这样的代码
能否把你的程式完善一下,求出满足条件的所有解? |
|
[分享]WinHex 12.25 RC3
这么简单的英文就不用汉化了吧?主要是要没有限制!功能超强,甚至可以恢复你删除的文件!偶一直在用。 曾经偶也用过UltraEdit,但还是觉得Winhex更强,更小巧! 只能说UltraEdit更花翘 就好象有人说“千千静音”更好,那是因为它有一个功能很方便! |
|
有人要练五笔吗?自己编的[原创][下载]
是粗糙了点,但也是本人精选的“字”,本软件注重难拆的“字”,如果跟别人的一样,又何必写这么一个程式?网上找一个更方便! |
|
[讨论]一个有趣的小游戏
猜数字游戏-人出题,电脑猜(转贴) /* * 文件名称: GuessNum.h * 程序描述: * 常见的小游戏【猜数字】的智能解法: * 猜数字游戏: 即有四位十进制数字,一般可猜8次 * 每次返回aAbB(A表示数字正确并且位置正确,B表示数字正确但位置不正确) * 如:假设要猜的数字是1234,如果游戏者猜0134即返回2A1B(3、4为A,1为B) * * 算法:每次选取熵最大的数字进行猜测,即:贪心算法 * * 还有一个程序使用决策树的方法,参见GuessNumAll.cpp * 另外还有一个程序GuessNumGame.cpp用来模拟猜数字游戏 */ #include <vector> #include <list> #include <string> using namespace std; class GuessNum { /* */ public: GuessNum(void); void Guess(void); void PrintStack(void); /* */ private: bool ConfirmAB(string first, string second, string ab); bool GuessNext(void); int GetABValue(string first, string second); const static int m_base[5]; string m_lastGuess; list<string> m_setAll; list<string> m_setCurr; vector<string> m_stack; int m_times; }; /* [01/19-21:54:50] 猜数字游戏: ? 即有四位十进制数字,一般可猜8次 ? 每次返回aAbB(A表示数字正确并且位置正确,B表示数字正确但位置不正确) ? 如:假设要猜的数字是1234,如果游戏者猜0134即返回2A1B(3、4为A,1为B) 思路: ? 模拟人猜数字的过程,先构造一个集合包括所有可能的数字(10*9*8*7=5040种),先乱猜一个,根据返回xAxB来把原来集合里面的不符合的都删掉,然后根据选取下一个。选下一个的原则是:选最能区分剩下的集合的那个数,即:被选择的那个数得到的返回值为xAxB中任意一种的概率差不多。 ? 我使用信息量的方法,即: ?? 对集合set(size个)中每一个数字n,用n的每一种返回值(从0a0b到4a0b,共有15种)做删减,看各剩下多少个,用pi表示第i种返回值得情况,然后根据信息量公式:info(n) = ∑(pi/size) * log(pi/size)计算,然后取max(info(i)) i=0..size;最大的那个info(n)对应的数字就是被选择的数字。 下面是一个由电脑猜数字的程序 猜(0-9)中4个全排列中的一个 现在我想修改成(1-9)中选4个全排列中一个. ------------------- 我修改的思路是:缩小全集范围 把带0的4位数字排除 下面红色为我修改的部分 修改第一次随机猜过滤带0的随机数 但修改结果:随机数仍然有0出现.全集也仍然有0 这里我想惭愧我之前没有学C++有些看不懂 但对C比较熟悉点.谁能帮小弟弟 指点迷津 或提出你修改的方法 小弟不胜感谢.因为急需这个程序.请帮我修改下 /* * 文件名称: GuessNum.cpp * 程序描述: 实现GuessNum类 */ #pragma warning(disable : 4786) #include <iostream> #include <algorithm> #include <ctime> #include <strstream> #include <cmath> #include "GuessNum.h" const int GuessNum:: m_base[5]={ 0, 5, 9, 12, 14 }; /* */ GuessNum::GuessNum(void) { m_times=0; //产生m_setAll unsigned int num=123; char a[10]; while(num < 10000) { bool valid=true; //表示数字没有重复 sprintf(a, "%04u", num); for(int i=0; i < 4; i++) { for(int j=i + 1; j < 4; j++) if(a[i] == a[j]) valid=false; } for(int q=0; q < 4; q++) if(a[q] == '0') valid=false; //红色部分为我添加的内容想缩小全集范围排除带0的数字 if(valid) m_setAll.push_back(a); num++; } //#while(num) } //#GuessNum() /* */ void GuessNum::Guess(void) { //重置数据集 m_setCurr.clear(); list<string>::iterator itCopy=m_setAll.begin(); while(itCopy != m_setAll.end()) m_setCurr.push_back(*itCopy++); m_stack.clear(); m_times=0; //随机产生第一次猜测 srand((unsigned)time(NULL)); //随机数种子 bool valid=false; unsigned int iCode; while(!valid) { iCode=rand(); while(iCode > 9999) iCode/=10; char a[10]; sprintf(a, "%04u", iCode); valid=true; for(int i=0; i < 4; i++) for(int j=i + 1; j < 4; j++) if(a[i] == a[j]) valid=false; for(int q=0; q < 4; q++) if(a[q] == '0') valid=false; //红色部分为我添加的内容想排除带0的随机4位数 if(valid) m_lastGuess=a; } while(!GuessNext()); } //#Guess() /* */ bool GuessNum::GuessNext(void) { m_times++; //进行猜测,获取猜测结果 string result; cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; PrintStack(); cout << "第 " << m_times << " 次猜测: " << m_lastGuess << endl; cout << "请输入结果[?A?B]:"; bool valid=false; while(!valid) { cin >> result; //判断输入是否合法 if(result.length() == 4 && result[0] >= '0' && result[0] <= '4' && result[2] >= '0' && result[2] <= '4' && (result[0] + result[2]) <= ('0' + '4') && toupper(result[1]) == 'A' && toupper(result[3]) == 'B') { valid=true; } if(!valid) cout << "输入不合法,请重新输入:"; } //#while //将结果入栈 strstream strm; strm << "第 " << m_times << "次: " << m_lastGuess << " -> " << result << endl; string strTemp; getline(strm, strTemp); m_stack.push_back(strTemp); if(result[0] != '4') { //尚未猜对, 进行数据集的约简 list<string>::iterator itRemove; itRemove=m_setCurr.begin(); while(itRemove != m_setCurr.end()) { if(!ConfirmAB(m_lastGuess, *itRemove, result)) itRemove=m_setCurr.erase(itRemove); else itRemove++; } //@@ if(m_setCurr.size() == 0) { cerr << "你检查一下,肯定是哪一步输入错误!" << endl; cerr << "程序结束" << endl; exit(1); } else if(m_setCurr.size() == 1) { m_lastGuess=m_setCurr.front(); return false; } //@@ cout << "m_setAll.size() = " << m_setAll.size() << endl; cout << "m_setCurr.size() = " << m_setCurr.size() << endl; //产生下一个猜测数据 double eMax=0; //max entropy, 最大信息量 string strMax; //提供最大信息量的那个数串 list<string>::iterator itEn=m_setCurr.begin(); //计算用每一个数来做区分时的信息量,取提供最大信息量的那个 double eCurr=0; int abList[15]; //从0a0b到4a0b共15种情况 memset(abList, 0, 15 * sizeof(int) / sizeof(char)); while(itEn != m_setCurr.end()) { list<string>::iterator itTemp=m_setCurr.begin(); while(itTemp != m_setCurr.end()) { abList[GetABValue(*itEn, *itTemp)]++; itTemp++; } //统计熵 //@@ // cout << "sigh.." << *itEn << endl; double eTemp=0; double eDiv=0; for(int i=0; i < 15; i++) { if(abList[i] != 0) //避免0*log0 { eDiv=double(abList[i]) / double(m_setCurr.size()); eTemp+= -eDiv * log(eDiv); } } if(eTemp > eMax) { cout << "here eMax = " << eMax << endl; eMax=eTemp; strMax=*itEn; } itEn++; } //#while(itEn) m_lastGuess=strMax; return false; } //#if(result[0] != 4) else // result[0] == 4 { cout << "\n答案是: " << m_lastGuess << endl; cout << "一共用了 " << m_times << "次" << endl; PrintStack(); return true; } } //#GuessNext() /* */ void GuessNum::PrintStack(void) { for(int i=0; i < m_stack.size(); i++) cout << m_stack[i] << endl; } //#PrintStack() /* */ inline bool GuessNum::ConfirmAB(string first, string second, string ab) { int a=0, b=0; for(int i=0; i < 4; i++) { for(int j=0; j < 4; j++) if(first[i] == second[j]) if(i == j) a++; else b++; } if(ab[0] == char(a + '0') && ab[2] == char(b + '0')) return true; else return false; } //#ConfirmAB() /* */ inline int GuessNum::GetABValue(string first, string second) { int a=0; int b=0; for(int i=0; i < 4; i++) { for(int j=0; j < 4; j++) if(first[i] == second[j]) if(i == j) a++; else b++; } return m_base[a] + b; } //#GetABValue() //测试程序 #include <iostream> #include "GuessNum.h" using namespace std; int main() { GuessNum gn; cout << "GuessNum object created..." << endl; gn.Guess(); return 0; } |
|
《加密与解密》(第二版)光盘补充资料下载
最初由 kanxue 发布 上面的连接出现错误!!!!!! |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值