Skip to content

Latest commit

 

History

History
24 lines (24 loc) · 460 Bytes

Q4.md

File metadata and controls

24 lines (24 loc) · 460 Bytes
public static void daosoFor(int n){
    List <Integer> list = new ArrayList<>();
    int flag = 0;
    if (n<0){
        n=-n;
        flag =1;
    }
    for (;n!=0;n=n/10 ){
        list.add(n%10);
        if (list.get(0)==0){
            list.remove(0);
        }
    }
    for (int j:list){
        if (flag ==1){
            System.out.print("-");
            flag ++;
        }
        System.out.print(j);
    }
    System.out.println(" ");
}