Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
palin
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; class palin { int l,c=0; String s,w="",t=""; char ch,ch1; void run() { Scanner sc=new Scanner(System.in); System.out.println("enter the sentence"); s=sc.nextLine(); l=s.length(); ch=s.charAt(l-1); if(ch!='.'&& ch!='?'&& ch!='!') { System.out.println("invalid input"); } else { for(int i=0;i<l;i++) { ch1=s.charAt(i); if(ch==' ' || ch=='?'|| ch=='!' || ch== '.') { if(w.equals(t)) { System.out.println(w+" "); c++; } w="";t=""; } else { w=w+ch; t=ch+t; } } } System.out.println("the no. of palindromic words is"+c); }}
run
|
edit
|
history
|
help
0
Problem: rstring
bit right 2
jb14.0 tests
JAVA # Dizi Ortalama
練習3-6
Test
ElaineBrown**
Prime Factors
FizzBuzz
메소드구현하기