引用第3楼lkk于2006-11-28 12:12发表的:操作数有几个啊,是不是多打了一个啊
/* A B C D E D F G + D F G ────── X Y Z D E */#include <stdio.h>#include <time.h>int main(){ int f1, f2, f3, r; long ftime, stime; short A, B, C, D, E, F, G, X, Y, Z; time( &ftime ); for( A = 0; A < 10; A++ ) { for( B = 0; B < 10; B++ ) { if( B == A )continue; for( C = 0; C < 10; C++ ) { if( C == A || C == B )continue; for( D = 0; D < 10; D++ ) { if( D == A || D == B || D == C )continue; for( E = 0; E < 10; E++ ) { if( E == A || E == B || E == C || E == D )continue; for( F = 0; F < 10; F++ ) { if( F == A || F == B || F == C || F == D || F == E )continue; for( G = 0; G < 10; G++ ) { if( G == A || G == B || G == C || G == D || G == E || G == F )continue; for( X = 0; X < 10; X++ ) { if( X == A || X == B || X == C || X == D || X == E || X == F || X == G )continue; for( Y = 0; Y < 10; Y++ ) { if( Y == A || Y == B || Y == C || Y == D || Y == E || Y == F || Y == G || Y == X )continue; for( Z = 0; Z < 10; Z++ ) { if( Z == A || Z == B || Z == C || Z == D || Z == E || Z == F || Z == G || Z == X || Z == Y )continue; f1 = A*10000 + B*1000 + C*100 + D*10 + E; f2 = D*100 + F*10 + G; f3 = X * 10000 + Y * 1000 + Z * 100 + D*10 + E; r = f1 + f2 + f2; if( r == f3 ) { printf( "A B C D E F G X Y Z\n" ); printf( "%d %d %d %d %d %d %d %d %d %d\n", A, B, C, D, E, F, G, X, Y, Z ); printf( "======================\n" ); } }// Z }// Y }// X }// G }// F }// E }// D }// C }// B }// A time( &stime ); printf( "time: %d\n", stime - ftime ); return 0;}
/* A B C D E D F G + D F G ────── X Y Z D E */#include <stdio.h>#include <time.h>int main(){ int f1, f2, f3, r; long ftime, stime; short A, B, C, D, E, F, G, X, Y, Z; time( &ftime ); for( A = 0; A < 10; A++ ) { for( B = 0; B < 10; B++ ) { if( B == A )continue; for( C = 0; C < 10; C++ ) { if( C == A || C == B )continue; for( D = 0; D < 10; D++ ) { if( D == A || D == B || D == C )continue; for( E = 0; E < 10; E++ ) { if( E == A || E == B || E == C || E == D )continue; for( F = 0; F < 10; F++ ) { if( F == A || F == B || F == C || F == D || F == E )continue; for( G = 0; G < 10; G++ ) { if( G == A || G == B || G == C || G == D || G == E || G == F )continue; for( X = 0; X < 10; X++ ) { if( X == A || X == B || X == C || X == D || X == E || X == F || X == G )continue; for( Y = 0; Y < 10; Y++ ) { if( Y == A || Y == B || Y == C || Y == D || Y == E || Y == F || Y == G || Y == X )continue; for( Z = 0; Z < 10; Z++ ) { if( Z == A || Z == B || Z == C || Z == D || Z == E || Z == F || Z == G || Z == X || Z == Y )continue; f1 = A*10000 + B*1000 + C*100 + D*10 + E; f2 = D*100 + F*10 + G; f3 = X * 10000 + Y * 1000 + Z * 100 + D*10 + E; r = f1 + f2 + f2; if( r == f3 ) { printf( "A B C D E F G X Y Z\n" ); printf( "%d %d %d %d %d %d %d %d %d %d\n", A, B, C, D, E, F, G, X, Y, Z ); printf( "======================\n" ); printf( "%6d\n%6d\n+%5d\n──────\n%6d\n", f1, f2, f2, r ); printf( "======================\n" ); } }// Z }// Y }// X }// G }// F }// E }// D }// C }// B }// A time( &stime ); printf( "time: %d\n", stime - ftime ); return 0;}