Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch10ex2;
- import java.util.ArrayList;
- public class Ch10Ex2
- {
- public static void main(String[] args)
- {
- ArrayList<Integer> nums=new ArrayList();
- ArrayList<Integer> index=new ArrayList();
- for(int c=0;c<=100;c++)
- {
- index.add(c);
- int temp=c;
- if(String.valueOf(c).length()==1)temp+=c;
- else if(String.valueOf(c).length()==2)temp+=(c/10)+(c%10);
- else temp+=(c/100)+((c%100)/10)+((c%100)%10);
- nums.add(temp);
- System.out.println(index.get(c)+"\t"+nums.get(c));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement