Palindrome – program

package day1;

public class Palindrome {

public static void main(String[] args) {
// TODO Auto-generated method stub
int no = 191;
int no2=no;
int reverse = 0;
while(no>0)
{
reverse = reverse*10 + no%10; no=no/10;
}
System.out.println(reverse);
if(reverse==no2)
System.out.println("palindram");
else
System.out.println("not palindram");
}}
out put == 191 palindram
public static void main(String[] args) {
    // TODO Auto-generated method stub
    int no = 191;
    int no2=no;

    int reverse = 0;
     while(no>0)
    {
    reverse = reverse*10 + no%10;              no=no/10;                                
    }
    System.out.println(reverse); 
if(reverse==no2)
    System.out.println("palindram");
else
    System.out.println("not palindram"); 


    }}

out put == 191  palindram
public static void main(String[] args) { // TODO Auto-generated method stub int no = 191; int no2=no; int reverse = 0; while(no>0) { reverse = reverse*10 + no%10; no=no/10; } System.out.println(reverse); if(reverse==no2) System.out.println("palindram"); else System.out.println("not palindram"); }} out put == 191 palindram

Enter fullscreen mode Exit fullscreen mode

原文链接:Palindrome – program

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享
Time and experience heals pain.
时间和经历会抚平一切伤痛
评论 抢沙发

请登录后发表评论

    暂无评论内容