Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1.  
  2. package node;
  3.  
  4. import com.oracle.jrockit.jfr.Transition;
  5. import java.util.Scanner;
  6.  
  7.  
  8. public class Swaggg{
  9.         static Scanner in = new Scanner(System.in);
  10.         private static boolean isEqual(Stack<Integer> s1, Stack<Integer> s2){
  11.   Stack<Integer> temp = new Stack<>();
  12.   Stack<Integer> temp1 = new Stack<>();
  13.   while(!s1.isemepty())
  14.   {
  15.  
  16.      while (!s2.isemepty()){
  17.          int x=s1.top();
  18.          int x2=s2.top();
  19.          if (x==x2){
  20.               System.out.println("swag");
  21.              break;
  22.          }
  23.          temp.push(s2.pop());
  24.          if(s2.isemepty()){
  25.              return false;
  26.          }
  27.         }
  28.          while (!temp.isemepty()){
  29.          s2.push(temp.pop());
  30.          }
  31.          
  32.          temp1.push(s1.pop());
  33.      }
  34.   while(!temp1.isemepty()){
  35.       s1.push(temp1.pop());
  36.  
  37. }
  38.   return true;
  39.         }
  40.         public static boolean DoSifrati(Stack<Integer> s1){
  41.             boolean Equel;
  42.             Stack<Integer> S1,S2,S3;
  43.             S1=new Stack<Integer>();
  44.             S2=new Stack<Integer>();
  45.             S3=new Stack<Integer>();
  46.             while (!s1.isemepty()){
  47.                int x=s1.pop();
  48.                S3.push(x);
  49.                S1.push(x/10);
  50.                S2.push(x%10);
  51.             }
  52.             while(!S3.isemepty()){
  53.                 s1.push(S3.pop());
  54.             }
  55.            Equel=isEqual(S1, S2);
  56.             return Equel;
  57.         }
  58.  
  59.      
  60.  public static void main(String[] args){
  61. Stack<Integer> s2=new Stack<Integer>();
  62. s2.push(13);
  63. s2.push(42);
  64. s2.push(31);
  65. s2.push(24);
  66. int n=110;
  67.      
  68.      System.out.println(DoSifrati(s2));
  69.      
  70.  }
  71.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement