Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. Input:
  2. 2
  3. Ophelia
  4. him
  5.  
  6. Output:
  7.  
  8. ACT I
  9. ACT I
  10.  
  11.  
  12. SCENE I. Elsinore. A platform before the castle.
  13. SCENE I. Elsinore. A platform before the castle.
  14.  
  15.  
  16. FRANCISCO at his post. Enter to him BERNARDO
  17. FRANCISCO at his post. Enter to *him* BERNARDO
  18.  
  19. static void bold( char bold, BufferedReader orders, BufferedReader in,BufferedWriter out ) throws IOException{
  20. String linha = in.readLine();
  21. boolean encontrou = false;
  22. String[] palavras = new String[Integer.parseInt(orders.readLine())];
  23. for(int i = 0; i < palavras.length; i++){
  24. palavras[i]=orders.readLine();
  25. }
  26.  
  27. while(linha != null){
  28. StringBuilder str = new StringBuilder(linha);
  29. for(int i = 0; i < palavras.length && !encontrou; i++){
  30.  
  31. if(linha.toLowerCase().indexOf(palavras[i]) != -1){
  32. str.insert((linha.toLowerCase().indexOf(palavras[i])),bold);
  33. str.insert((linha.toLowerCase().indexOf(palavras[i]))+palavras[i].length()+1, bold);
  34. out.write(str.toString());
  35. out.newLine();
  36.  
  37. }
  38. else{
  39. out.write(linha);
  40. out.newLine();
  41. }
  42. }
  43. linha = in.readLine();
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement