Advertisement
Maruf_Hasan

Shafi

Oct 15th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. package n1707026;
  2. import java.io.FileNotFoundException;
  3. import java.util.Scanner;
  4. import java.io.File;
  5. import java.io.FileWriter;
  6. import java.io.IOException;
  7. class mythread extends Thread{
  8. String s;
  9. mythread(String s1)
  10. {
  11. s=s1;
  12. }
  13. public void run() {
  14. int count = 0,x,i,j;
  15. x=s.length();
  16. for(i=0,j=(x-1);i<(x/2);i++,j--) {
  17. char a,b;
  18. a=s.charAt(i);
  19. b=s.charAt(j);
  20. if(a==b) {
  21. count++;
  22. }
  23. //System.out.print(s.charAt(i));
  24. }
  25. if(count==x || count==(x-1)) {
  26. System.out.println("Palindrome");
  27. }
  28. else
  29. System.out.println("Not Palindrome");
  30. //System.out.println(x);
  31. }
  32. }
  33. public class labtest {
  34. public static void main(String[] args) throws IOException {
  35. File infile=new File("input.txt");
  36. FileWriter outfile=new FileWriter("output.txt");
  37. try {
  38. Scanner input1=new Scanner(infile);
  39. //mythread t=new mythread;
  40. for(int i=0;input1.hasNextLine();i++)
  41. {
  42. String out=input1.nextLine();
  43. //outfile.write(out);
  44. //outfile.close();
  45. mythread t1=new mythread(out);
  46. //t1[i]=new mythread(out);
  47. t1.start();
  48. System.out.println(out);
  49.  
  50. }
  51. }catch(FileNotFoundException e) {
  52. e.printStackTrace();
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement