Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class Liste{
  2. int a;
  3. Liste b;
  4. Liste ( int c,Liste d){
  5. this.b=d;
  6. this.a=c;
  7. }
  8. public String toString(){
  9. if ( b == null) {
  10. return "" + a;
  11. }
  12. else {
  13. return "" +a + " " +b.toString();
  14. }
  15. }
  16. public void anhaenge (Liste NEU){
  17.  
  18. if (b==null){
  19. b=NEU;
  20. NEU.b=null;
  21. }
  22. else{
  23. b.anhaenge(NEU);
  24. }
  25. }
  26. public void kopiere(){
  27.  
  28.  
  29. public void erhoehe(){
  30. if ( b!= null){
  31. a = a+10;
  32. b.erhoehe();
  33. }
  34. else{
  35. a = a+10;
  36. }
  37. }
  38. }
  39.  
  40.  
  41.  
  42.  
  43. public class P9_1{
  44. public static void main (String[]args){
  45. int n=Integer.parseInt(args[0]);
  46. // Liste test = new Liste (n,null)
  47. Liste test = null;
  48. for (int i = n; i>0;i--) {
  49. test = new Liste (i,test);
  50. }
  51. Liste Test = new Liste (10,null);
  52. System.out.println(test.toString());
  53. test.anhaenge(Test);
  54. System.out.println(test.toString());
  55.  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement