google竞赛题SecretSum的C++解法
???????????POS ps={i,j}; ????????????????m_letterPos[ch[j]-''''A''''].push_back(ps);//??×?±ê±£′?μ??àó|?òá??D ????????????} ????????????//?????÷??×???μ??¥?????ó ????????????if ( ch[0]==ch[1]) m_linePattern[i][0]=1; ????????????if ( ch[0]==ch[2]) m_linePattern[i][1]=1; ????????????if ( ch[1]==ch[2]) m_linePattern[i][2]=1; ????????} ????????for ( i = 0; i<26; i++) ????????{ ????????????if (m_letterPos[i].size()>0) ????????????????m_posptrVec.push_back(&m_letterPos[i]);//???ùóD3???μ?×????òá?????±£′??eà′ ????????} ????} ????int IfMatch(int *maybe) ????{ ????????char numChar[3][4]; ????????int bUse[10]={0}; ????????int i,j; ????????for ( i = 0 ; i <3; i++) ?????????? sprintf(numChar[i],"%d",maybe[i]);//??êy×?×a??3é×?·?′? ????????for ( i = 0; i < m_posptrVec.size(); i++)//±éàú?ùóD3???μ?×??? ????????{ ????????????POSVEC &ps= (*m_posptrVec[i]); ????????????int ch = numChar[ps[0].dim1][ps[0].dim2]-''''0'''';//è?μ???×???μúò???????′|μ?êy×? ????????????if ( bUse[ch] ) return 0; //è?1?êy×?ò?±?ê1ó??í·μ??0 ???????????????? ????????????//?eò?±è??????????3?μ?êy×?ê?·????àí? ????????????j=1; ????????????while( j < ps.size() ) ????????????{ ????????????????int ch2 = numChar[ps[j].dim1][ps[j].dim2]-''''0''''; ????????????????if (ch != ch2 ) return 0; ????????????????j++; ????????????} ????????????bUse[ch] = 1;//????êy×?éè???aò?±?ê1ó? ????????} ????????return 1; ????} ????int IfNumOk(int idx, int num) ????{ ????????char temp[4]; ????????int??com[3]={0}; ????????sprintf(temp,"%d",num);//??êy×?×a??3é×?·?′? ????????//????′?è?êy×?μ??¥???á1? ????????if (temp[0] == temp[1] ) com[0]=1; ????????if (temp[0] == temp[2] ) com[1]=1; ????????if (temp[2] == temp[1] ) com[2]=1; ????????//ó??÷òy?aidxμ?×?·?′??¥???á1?±è?? ????????for ( int i=0; i< 3; i++) ????????????if ( com[i] != m_linePattern[idx][i]) return 0; ????????return 1; ????} protected: ????POSVEC??????m_letterPos[26];????//±£′?????×???μ?3????????òá?μ?êy×é ????POSPTRVEC?? m_posptrVec;????????//±£′?3???μ?×????òá?μ????? ????int???????? m_linePattern[3][3];//±£′?????×?·?′??¥??ààDíμ?êy×é }; èy?¢D??á ê1ó?é?ê?μ?′ú????ìa?D??3?7??êμày??DDêμ2aê±£??ò·¢??ày5μ?????1y3ì×??y?£ò?·???·¢???-à′ày5?Dμ?num1,num2,result,??ê?{0,0,0}Díμ?£??a?ù×???IfMatch±?μ÷ó?á?117662′??£???úày4?Dnum1oínum2í??ùê?{0,0,0}Díμ?£?μ?óéóúresult?a{1,1,1}Dí£?ê?êμé?IfMatch×?????±?μ÷ó?á?2144′?£?????ó?ê±éD?üèìêü?£óé′??é??£??òμ?′ú????óúnum1,num2,??ê?{0,0,0}Díμ??????1óDó??ˉμ?óàμ?£??Tóúê±??oí??á|?ò??óD?ìD?ó??ˉ??è¥?£??ó-?÷????ê?£?12í?ì?ì?£???3??üó?μ??a??·?°??£ |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |