Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- class lista{
- String val;
- lista st,dr;
- public lista(String val1) {
- val=val1;
- }
- public lista() {}
- }
- public class p1 {
- static void citire(lista x) throws IOException{
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- String text=br.readLine();
- x.val=text;
- if(text.compareTo("f") !=0) {
- x.st=new lista();
- x.dr=new lista();
- citire(x.st);
- citire(x.dr);
- }
- }
- static void afisare_preorder(lista x){
- System.out.println(x.val);
- if(x.st!=null) afisare_preorder(x.st);
- else {
- System.out.println(x.val);
- x=x.dr;
- }
- }
- public static void main(String[] args) throws IOException {
- lista nod=new lista("abc");
- citire(nod);
- afisare_preorder(nod);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement