Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package n1707026;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- class mythread extends Thread{
- String s;
- mythread(String s1)
- {
- s=s1;
- }
- public void run() {
- int count = 0,x,i,j;
- x=s.length();
- for(i=0,j=(x-1);i<(x/2);i++,j--) {
- char a,b;
- a=s.charAt(i);
- b=s.charAt(j);
- if(a==b) {
- count++;
- }
- //System.out.print(s.charAt(i));
- }
- if(count==x || count==(x-1)) {
- System.out.println("Palindrome");
- }
- else
- System.out.println("Not Palindrome");
- //System.out.println(x);
- }
- }
- public class labtest {
- public static void main(String[] args) throws IOException {
- File infile=new File("input.txt");
- FileWriter outfile=new FileWriter("output.txt");
- try {
- Scanner input1=new Scanner(infile);
- //mythread t=new mythread;
- for(int i=0;input1.hasNextLine();i++)
- {
- String out=input1.nextLine();
- //outfile.write(out);
- //outfile.close();
- mythread t1=new mythread(out);
- //t1[i]=new mythread(out);
- t1.start();
- System.out.println(out);
- }
- }catch(FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement