POJ1219 L-I-N-G-O: LINGO
来源:互联网 发布:设ab都是n阶对称矩阵 编辑:程序博客网 时间:2024/04/30 03:33
题目:http://acm.pku.edu.cn/JudgeOnline/problem?id=1219
思路:题目不难,但千万读清楚题,输入输出也有陷阱。。。
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class Main {
- public static void main(String[] args) throws IOException {
- BufferedReader read = new BufferedReader(new InputStreamReader(
- System.in));
- String s;
- String r;
- int time;
- char[] last;
- StringBuilder temp;
- char[] buff;
- int pos;
- boolean[] used;
- game: while (!(s = read.readLine()).equals("LINGO")) {
- if (s.equals("") || s == null) {
- continue;
- }
- System.out.println();
- r = s;
- last = new char[] { '.', '.', '.', '.', '.' };
- last[0] = r.charAt(0);
- System.out.println(last);
- time = 1;
- turn: while (!(s = read.readLine()).equals("")) {
- // check valid
- if (s.length() != 5) {
- System.out.println(last);
- time++;
- continue turn;
- }
- for (int i = 0; i < 5; i++) {
- if (!Character.isUpperCase(s.charAt(i))) {
- System.out.println(last);
- time++;
- continue turn;
- }
- }
- // is right
- if (s.equals(r)) {
- System.out.println(r);
- over(read);
- continue game;
- }
- if (time == 6) {
- System.out.println(r.toLowerCase());
- over(read);
- continue game;
- }
- // check
- buff = new char[] { '.', '.', '.', '.', '.' };
- temp = new StringBuilder(r);
- used = new boolean[5];
- for (int i = 0; i < 5; i++) {
- if (r.charAt(i) == s.charAt(i)) {
- buff[i] = s.charAt(i);
- temp.setCharAt(i, ' ');
- used[i] = true;
- }
- }
- for (int i = 0; i < 5; i++) {
- if (used[i]) {
- continue;
- }
- if ((pos = temp.indexOf(s.charAt(i) + "")) != -1) {
- buff[i] = Character.toLowerCase(s.charAt(i));
- temp.setCharAt(pos, ' ');
- used[i] = true;
- }
- }
- System.out.println(buff);
- last = buff;
- time++;
- }
- if (time < 7) {
- System.out.println(r.toLowerCase());
- }
- }
- }
- public static void over(BufferedReader read) throws IOException {
- while (!read.readLine().equals("")) {
- }
- }
- }
- POJ1219 L-I-N-G-O: LINGO
- K D E是基于Troll Te c h n o l o g i e s公司的Q t库的
- Te r m i n a t e T h r e a d函数是异步运行的函数,必须调用Wa i t F o r S i n g l e O b j e c t
- 基础地理信息术语(a-b-c-d-e-f-g-h-i-k-l-m-n-o-t-u-v-w-x-y-z)
- Wi n d o w s函数l s t r c m p和l s t r c m p i是作为对Wi n d o w s函数 C o m p a r e S t r i n g的调用来实现
- 用于C U I应用程序:/ S U B S Y S T E M : C O N D O L E,而用于G U I :S U B S Y S T E M : W
- gcc 选项 -c -I -o -L -l
- g++ -L 和-l && -I参数
- g++ -L 和-l && -I参数
- 如果令 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 分别等于
- Linux中error while loading shared libraries错误解决办法
- S.O.L.I.D 原则
- S.O.L.I.D 原则
- 【C#】S.O.L.I.D
- Oracle_11gR2_SCAN_IP scan ip配置详解
- java,v-o-l-a-t-i-l-e
- Oracle的Union、Union_All、Intersect、Minus用法---小笔记
- C#中String类的几个方法(IndexOf、LastIndexOf、Substring)
- sql 2005 登陆问题
- 铁杵终能磨成针
- mysql优化: 内存表和临时表
- freemarker学习笔记
- Javascript中最常用的55个经典技巧
- POJ1219 L-I-N-G-O: LINGO
- SQL Server 2005新语法
- 哈佛图书馆墙上的训言
- Yahoo!网站性能最佳体验的34条黄金守则——内容
- Yahoo!网站性能最佳体验的34条黄金守则——服务器
- QQ宠物等级 宠物总的成长值 省级所需成长值 增加值
- js中动态修改frame的src属性,frame自己刷新。。。
- Yahoo!网站性能最佳体验的34条黄金守则——JavaScript和CSS
- Yahoo!网站性能最佳体验的34条黄金守则——图片、Coockie与移动应用