Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public class Langzeitarithmetik
  2. {
  3. public static int[] zweimal(int zahl[])
  4. {
  5. for(int i=19; i>-1; i--)
  6. {
  7. zahl[i] = zahl[i] * 2;
  8. zahl[i+1] = zahl[i+1] + zahl[i] / 10;
  9. zahl[i] = zahl[i] % 10;
  10. }
  11. return zahl;
  12. }
  13.  
  14. public static int[] zahlPlus(int zahl[], int gesamtZahl[])
  15. {
  16. for(int i=19; i>-1; i--)
  17. {
  18. gesamtZahl[i] += zahl[i];
  19. gesamtZahl[i+1] = gesamtZahl[i+1] + gesamtZahl[i] / 10;
  20. gesamtZahl[i] = gesamtZahl[i] % 10;
  21. }
  22. return gesamtZahl;
  23. }
  24.  
  25. public static void main(String args[])
  26. {
  27. int zahl[] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  28. int gesamtZahl[] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  29. for(int i=0; i<63; i++)
  30. {
  31. zahl = zweimal(zahl);
  32. gesamtZahl = zahlPlus(zahl, gesamtZahl);
  33. }
  34. for (int i=20; i>-1; i--)
  35. {
  36. System.out.print("" + gesamtZahl[i]);
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement