hw 校招机试

 1 package test;
 2 
 3 import java.util.Scanner;
 4 
 5 public class Main {
 6 
 7     public static void main(String[] args) {
 8         // TODO Auto-generated method stub
 9         Scanner in = new Scanner(System.in);
10         int a = 0, n = 0;
11         int ans = 0;
12         while(in.hasNext()){
13             a = in.nextInt();
14             n = in.nextInt();
15             ans = countsum(a,n);
16             System.out.println(ans);
17         }
18     }
19     
20     public static int countsum(int a,int n){
21         int sum = 0,tmp = a;
22         for(int i = 0; i < n; i++){
23             sum += tmp;
24             tmp = tmp*10 + a;
25         }
26         return sum;
27     }
28 
29 }
30 
31 
32 package test;
33 
34 import java.util.Scanner;
35 
36 public class Main {
37 
38     public static void main(String[] args) {
39         // TODO Auto-generated method stub
40         Scanner in = new Scanner(System.in);
41         int max = 0, min = 0;
42         int cnt = 0;
43         String[] numstr;
44         if(in.hasNext()){
45             String str = in.nextLine();
46             numstr = str.split(",");
47             int[] num = new int[numstr.length];
48             for(int i = 0; i < numstr.length; i++){
49                 num[i] = Integer.parseInt(numstr[i]);
50             }
51             max = num[0];min = num[0];
52             for(int i = 0; i < num.length; i++){
53                 if(num[i] > max) {
54                     min = max;
55                     max = num[i];
56                 }
57                 else if(num[i] > min) {
58                     min = num[i];
59                 } 
60             }
61                 
62         }
63         System.out.println(max + "," + min);
64     }
65 }

 

posted @ 2016-08-22 11:16  Miller1991  阅读(155)  评论(0编辑  收藏  举报