Bài đăng

Đang hiển thị bài đăng từ Tháng 7, 2019

Xâu đối xứng n phần tử

/*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; /**  *  * @author Le Thi Tuyet  */ public class Solution {     /**      * @param args the command line arguments      */         public static void main(String[] args) throws FileNotFoundException {         // TODO code application logic here         System.setIn(new FileInputStream("input.txt"));         int testcase = 1;                 Scanner sc = new Scanner(System.in);         for(int i=0; i<testcase; i++){             String s = sc.ne...

Xâu đối xứng

/*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; /**  *  * @author Le Thi Tuyet  */ public class Solution {     /**      * @param args the command line arguments      */         public static void main(String[] args) throws FileNotFoundException {         // TODO code application logic here         System.setIn(new FileInputStream("input.txt"));         int testcase = 2;                 Scanner sc = new Scanner(System.in);         for(int i=0; i<testcase; i++){             String s = sc.ne...

Dịch xâu k lần

package ArrayProcessing; public class Mang { static void print(int []array) { int len = array.length; for(int i=0; i<len; i++) { System.out.print(array[i]+" "); } System.out.println(); } static int[] dich(int []array, int solanxoay) { int len = array.length; int luu = 0; for(int i=0; i<len; i++) { if(i==0) luu = array[i]; array[i]=array[(i+solanxoay)%len]; } array[len-1]=luu; return array; } public static void main(String[] args) { // int []a = {1,2,3,4,1}; // print(a); // for(int i=0; i<4; i++) { // print(dich(a,1)); // } } }

Stack-Biểu thức đúng

package ArrayProcessing; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class MyStack { private int maxSize;    private char[] stackArray;    private int top;    public MyStack(int s) {       maxSize = s;       stackArray = new char[maxSize];       top = -1;    }    public void push(char j) {       stackArray[++top] = j;    }    public char pop() {       return stackArray[top--];    }      public boolean isEmpty() {       return (top == -1);    }    static int check(String s) {    MyStack myStack = new MyStack(10);    int kt = 0;      for(int i=0; i<s.length(); i++) {     if(s.charAt(i)=='{' || s.charAt(i)=='[' || s.charAt(i)...