Advertisement
fkrone

calctri

Feb 22nd, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. public class calctri {
  2.     public static void main(String[] args) {
  3.         int a;  //Zahl 1
  4.         int b;  //Zahl 2
  5.         int c;  //Zahl 3
  6.         int max=2012;   //Maximale Zahl
  7.         int s;  //Summe der Zahlen a+b+c
  8.         long n=0L;  //Anzahl
  9.        
  10.         for (a=0; a <= max; a++) {
  11.             //System.out.println(a);
  12.             for (b=a+1; b<=max; b++) {
  13.                 //System.out.println("a="+a+" b="+b);
  14.                 for (c=b+1; c<=max; c++) {
  15.                     //System.out.println("a="+a+" b="+b+" c="+c);
  16.                     s = a+b+c;
  17.                     if (s%3 == 0) {
  18.                         n=n+1;
  19.                         System.out.println("a="+a+" b="+b+" c="+c);
  20.                         //System.out.println("DEBUG!! "+n);
  21.                     }   //end of if
  22.                 }   //end of for-loop c
  23.             }   //end of for-loop b
  24.         }   //end of for-loop a
  25.         System.out.println("Die Anzahl der Tripel beträgt: "+n);
  26.     }   //end of main
  27. }   //end of class calctri
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement