|
沙发
楼主 |
发表于 2014-11-4 21:39:50
|
只看该作者
1.- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int h,a,joke;bool b[10];
- int main()
- {
- for(h=1;h<=9;h++)
- {
- b[h]=1;
- for(a=0;a<=9;a++)
- if(!b[a])
- {
- b[a]=1;
- long ahhaah=11001*h+100110*a,ha=10*h+a;
- if(ahhaah/ha*ha==ahhaah)
- {
- joke=ahhaah/ha;
- while(joke)
- {
- int p=joke%10;joke/=10;
- if(b[p])break;
- }
- if(joke)continue;
- else cout<<ahhaah<<"/"<<ha<<"="<<ahhaah/ha;
- }
- b[a]=0;
- }
- b[h]=0;
- }
- return 0;
- }
复制代码
2.- #include<iostream>
- #include<cmath>
- using namespace std;
- int one,two;bool b[10];
- void print()
- {
- cout<<one<<"+"<<one<<"="<<two<<endl;
- }
- int main()
- {
- cout<<"ONE+ONE=TWO"<<endl;
- for(int oneo=2;oneo<=4;oneo+=2)
- {
- b[oneo]=1;
- for(int onen=0;onen<=9;onen++)
- if(!b[onen])
- {
- b[onen]=1;
- for(int onee=1;onee<=7;onee++)
- if(!b[onee])
- {
- b[onee]=1;
- one=100*oneo+10*onen+onee;
- two=2*one;
- int twoo=two%10,twow=(two/10)%10,twot=two/100;
- if(twoo==oneo&&!b[twow]&&!b[twot]&&twow!=twot)print();
- b[onee]=0;
- }
- b[onen]=0;
- }
- b[oneo]=0;
- }
- return 0;
- }
复制代码 |
|