ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1601. AntiCAPS

Please help me
Posted by Meni Packeou 17 Aug 2008 13:00
This is My code.Time limit exid at the 10 test.
Help me?

import java.util.*;
import java.io.*;

public class Chat1 implements Runnable{
 public static void main(String args[]){
     new Thread(new Chat1()).start();
 }
 BufferedReader in;
 PrintWriter out;
 ArrayList<String> ls;
 public void run(){
      try{
       in = new BufferedReader(new InputStreamReader(System.in));
       ls=new ArrayList<String>();
       out = new PrintWriter(new OutputStreamWriter(System.out));
       solve();
       out.flush();

      }catch(IOException e){
        throw new IllegalStateException(e);

      }
 }
 void solve()throws IOException{
        String s1="",s="";
    char ch;
    int k=0,k3=0;
        boolean p=true;

    while((k3=in.read())!=-1){

                        ch=(char)k3;
            if(p && ch!=' ' && ch!='.' && ch!='!' && ch!='?' && ((int)ch>=65 && (int)ch<=90)){
                s+=ch;
                p=false;

            }
            else{
                if(ch=='!' || ch=='?' || ch=='.'){
                    p=true;
                    s+=ch;
                }
                else{
                                     if((int)ch>=65 && (int)ch<=90)  s+=(char)((int)ch+32);
                                         else  s+=ch;
                                }
            }








        }
          out.print(s);

  }
}