1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import java.util.Scanner; /** * UVA10252 */ public class UVA10252 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] n1, n2; while (sc.hasNextLine()) { String str1 = sc.nextLine(), str2 = sc.nextLine(); n1 = new int[26]; n2 = new int[26]; for (int i = 0; i < str1.length(); i++) if (str1.charAt(i) >= 97 && str1.charAt(i) <= 122) n1[str1.charAt(i) - 97]++; for (int i = 0; i < str2.length(); i++) if (str2.charAt(i) >= 97 && str2.charAt(i) <= 122) n2[str2.charAt(i) - 97]++; for (int i = 0; i < 26; i++) { int min = Math.min(n1[i], n2[i]); for (int j = 0; j < min; j++) System.out.print((char) (i + 97)); } System.out.println(); } } } |
月份: 2018 年 5 月
Java – UVA10222
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import java.util.Scanner; /** * UVA10222 */ public class UVA10222 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String chars = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./'"; String temp = null; while (sc.hasNextLine()) { temp = sc.nextLine().toLowerCase(); for (int i = 0; i < temp.length(); i++) { char c = temp.charAt(i); if (c == ' ') System.out.print(' '); else { int index = chars.indexOf(temp.charAt(i)); System.out.print(chars.charAt(index - 2)); } } System.out.println(); } sc.close(); } } |
Java – UVA10008
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import java.util.Scanner; /** * UVA10008 */ public class UVA10008 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String temp = sc.nextLine(); temp = temp.replace(" ", ""); int num = Integer.parseInt(temp); int[] count = new int[26]; int max = 0; for (int i = 0; i < num; i++) { temp = sc.nextLine().toLowerCase(); for (int j = 0; j < temp.length(); j++) { if (temp.charAt(j) <= 122 && temp.charAt(j) >= 97) { count[temp.charAt(j) - 97]++; if (count[temp.charAt(j) - 97] > max) max = count[temp.charAt(j) - 97]; } } } for (int i = max; i > 0; i--) for (int j = 0; j < count.length; j++) { if (i == count[j]) System.out.println((char) (j + 65) + " " + count[j]); } sc.close(); } } |
Java – UVA490
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * UVA490 */ public class UVA490 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); List<String> input = new ArrayList<String>(); int max = 0; int maxLine = 0; while (sc.hasNextLine()) { String temp = sc.nextLine(); input.add(temp); if (max <= temp.length()) { max = temp.length(); maxLine = input.size() - 1; } } for (int i = 0; i < max; i++) { for (int j = input.size() - 1; j >= 0; j--) { String temp = input.get(j); if (temp.length() > i) System.out.print(temp.charAt(i)); else if (j > maxLine) System.out.print(" "); } System.out.println(); } sc.close(); } } |
Java – UVA272
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import java.util.Scanner; /** * UVA272 */ public class UVA272 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); boolean symbol = false; while (sc.hasNextLine()) { String temp = sc.nextLine(); for (int i = 0; i < temp.length(); i++) { if (temp.charAt(i) == '\"') { if (!symbol) System.out.print("<code></code>"); else System.out.print("\'\'"); symbol = !symbol; } else System.out.print(temp.charAt(i)); } System.out.println(); } sc.close(); } } |