Guest User

Untitled

a guest
Mar 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class Symbolraetsel here.
  4.  *
  5.  * @author King Kong
  6.  * @version 1.0 (13.08.1961)
  7.  */
  8. public class Symbolraetsel
  9. {
  10.    public static void main(String[] args)
  11.    {
  12.     int summand1;
  13.     int summand2;
  14.     int summe1;
  15.     int count=0;
  16.     for (int h=1; h<=9; h++)
  17.     {
  18.         for (int e=0; e<=9; e++)
  19.         {
  20.             if (e==h)
  21.                 continue;
  22.             for (int s=0; s<=9; s++)
  23.             {
  24.                 if (s==h || s==e)
  25.                     continue;
  26.                 for (int t=1; t<=9; t++)
  27.                 {
  28.                     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))
  29.                         continue;
  30.                     for (int b=1 ;b<=9; b++)
  31.                     {
  32.                         if (b==h || b==e || b==s || b==t)
  33.                             continue;
  34.                         count++;
  35.                         summand1 = h*100 + e*10 + s;
  36.                         summand2 = t*100 + h*10 + e;
  37.                         summe1 = b*1000 + e*100 + s*10 + t;
  38.                         if ((summand1 + summand2) == summe1)
  39.                             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+"!");
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.     }
  45.     System.out.println("Es konnte keine weitere gültige Lösung gefunden werden. Versuche: "+count);
  46.    }
  47. }
Add Comment
Please, Sign In to add comment