Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Liste{
- int a;
- Liste b;
- Liste ( int c,Liste d){
- this.b=d;
- this.a=c;
- }
- public String toString(){
- if ( b == null) {
- return "" + a;
- }
- else {
- return "" +a + " " +b.toString();
- }
- }
- public void anhaenge (Liste NEU){
- if (b==null){
- b=NEU;
- NEU.b=null;
- }
- else{
- b.anhaenge(NEU);
- }
- }
- public void kopiere(){
- public void erhoehe(){
- if ( b!= null){
- a = a+10;
- b.erhoehe();
- }
- else{
- a = a+10;
- }
- }
- }
- public class P9_1{
- public static void main (String[]args){
- int n=Integer.parseInt(args[0]);
- // Liste test = new Liste (n,null)
- Liste test = null;
- for (int i = n; i>0;i--) {
- test = new Liste (i,test);
- }
- Liste Test = new Liste (10,null);
- System.out.println(test.toString());
- test.anhaenge(Test);
- System.out.println(test.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement