Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class Symbolraetsel here.
- *
- * @author King Kong
- * @version 1.0 (13.08.1961)
- */
- public class Symbolraetsel
- {
- public static void main(String[] args)
- {
- int summand1;
- int summand2;
- int summe1;
- int count=0;
- for (int h=1; h<=9; h++)
- {
- for (int e=0; e<=9; e++)
- {
- if (e==h)
- continue;
- for (int s=0; s<=9; s++)
- {
- if (s==h || s==e)
- continue;
- for (int t=1; t<=9; t++)
- {
- if (t==h || t==e || t==s || ((s+e)%10) != t || (e+s<10 && (e+h)%10 != s) || (e+s>10 && (e+h+1)%10 != s) || (e+s>10 && e+h+1> 10 && (h+t+1)%10!=e) || (s+e<10 && e+h<10 && (h+t)%10!=e) || (s+e<10 && e+h>10 && (h+t+1)%10!=e) || (s+e>10 && h+e+1<10 && (h+t)%10!=e))
- continue;
- for (int b=1 ;b<=9; b++)
- {
- if (b==h || b==e || b==s || b==t)
- continue;
- count++;
- summand1 = h*100 + e*10 + s;
- summand2 = t*100 + h*10 + e;
- summe1 = b*1000 + e*100 + s*10 + t;
- if ((summand1 + summand2) == summe1)
- System.out.println("Mit h="+h+",e="+e+",s="+s+",t="+t+" und b="+b+", ergibt sich die Rechnung "+h+e+s+"+"+t+h+e+"="+b+e+s+t+"!");
- }
- }
- }
- }
- }
- System.out.println("Es konnte keine weitere gültige Lösung gefunden werden. Versuche: "+count);
- }
- }
Add Comment
Please, Sign In to add comment