خرید بک لینک

first sorry about my English(not my native language). I am new in programming (currently leaing Java) and just finishing lecture about looping. I had a task to reverse random number from 1 to 9999, and got stuck with a bug zero:

example: 23100 output:132 and solution is 00132

Since I still don't know Arrays, convert to String(manipulation),object solution etc…. I couldn't find begier solution for this problem.
Since this page helped me a lot, I decided to, maybe help someone: this is begiers solution to problem:

123 reverse 321

12300 reverse to 00321 // bug problem with zero solved

now I am still stuck with problem : 00123 and output 32100 not 321 but hope solve this soon

Best regards

import java.util.Scaer;
public class MP{
public static void main(String[] args){
Scaer input=new Scaer(System.in);
System.out.print("enter number:n");
int x=input.nextInt();
int temp=x;
int z;
    while(temp>0){
    z=temp%10;
         if(z==0){
            System.out.printf("%d",0);
        }else{
            System.out.printf("%d",z);
        } 
    temp=temp/10;
 }}}

- - , .

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 4 اسفند 1394 ساعت: 0:00

صفحه بندی