今日一言:
谢谢你,成为我前进的理由。
——《言叶之庭》
数据结构 —— 三羊献瑞
C语言实现
/*********************************************************************************
*
* 三羊献瑞 (暴力破解)
* create: 2020年5月24日 23点17分
* author: LOS(小鱼)
*
* *******************************************************************************/
#include<stdio.h>
void main(){
int a; //祥
int b; //瑞
int c; //生
int d; //辉
int e = 1; //三,易知
int f; //羊
int g; //献
int h; //气
int fir,sec,res,ver;
for ( a = 0; a<10; a++ ){
for ( b = 0; b<10; b++ ){
for ( c = 0; c<10; c++ ){
for ( d = 0; d<10; d++ ){
for ( f = 0; f<10; f++ ){
for ( g = 0; g<10; g++ ){
for ( h = 0; h<10; h++ ){
if( a==b || a==c || a==d || a==e || a==f || a==g || a==h ) continue;
if( b==c || b==d || b==e || b==f || b==g || b==h ) continue;
if( c==d || c==e || c==f || c==g || c==h ) continue;
if( d==e || d==f || d==g || d==h ) continue;
if( e==f || e==g || e==h ) continue;
if( f==g || f==h ) continue;
fir = a*1000 + b*100 + c*10 + d*1;
sec = e*1000 + f*100 + g*10 + b*1;
res = e*10000+ f*1000+ c*100+ b*10+ h*1;
if( fir + sec == res ){
printf("三 --> %d
",e);
printf("羊 --> %d
",f);
printf("献 --> %d
",g);
printf("瑞 --> %d
",b);
return;
}
}
}
}
}
}
}
}
}
运行结果
三 --> 1
羊 --> 0
献 --> 8
瑞 --> 5
--------------------------------
Process exited after 0.2048 seconds with return value 9
请按任意键继续. . .