Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner in = new Scanner(System.in);
- List cadeira = new List();
- List cursar = new List();
- String leitor = "";
- String quero = "";
- int cont = 0;
- int c = Integer.parseInt(in.nextLine());
- for (int i = 0; i < c; i++) {
- leitor = in.nextLine();
- cadeira.inserir(leitor);
- }
- System.out.println(cadeira.cont(0));
- while (in.hasNext()) {
- quero = in.nextLine();
- cont++;
- }
- String dej []= new String[cont];
- for (int i = 0; i < cont; i++) {
- if (cadeira.getDisci() == cursar.getDisci()) {
- }
- }
- }
- }
- class List {
- private String disci;
- private String req;
- private List next;
- public List() {
- this.disci = null;
- this.next = null;
- }
- public String getDisci() {
- return this.disci;
- }
- public void setDisci(String disci) {
- this.disci = disci;
- }
- public void inserir(String disci) {
- if (this.disci == null) {
- this.disci = disci;
- this.next = new List();
- } else {
- this.next.inserir(disci);
- }
- }
- public void verificar(String req) {
- if (req.equals(this.disci)) {
- this.req = disci;
- this.next = new List();
- } else if (this.req != null) {
- this.next.verificar(req);
- }
- }
- public int cont(int cont) {
- if (this.disci != null) {
- cont = this.next.cont(cont + 1);
- }
- return cont;
- }
- public boolean x(String disci) {
- if (this.disci.equals(disci) && this.disci != null) {
- return true;
- } else if (!(this.disci.equals(disci)) && this.disci != null) {
- return this.next.x(disci);
- }
- return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement