First, solve the problem. Then, write the code. ” - John Johnson

It's not at all important to get it right the first time. It's vitally important to get it right the last time. ” - Andrew Hunt and David Thomas

Wednesday, July 16, 2014

TEX Quotes

Author : Jisan
Programming language : Java
Difficulty : A little advance.
Status : Accepted in c programming of mine. :P
Problem number : UVA-272
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=208

Help: http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html

Alert: You can change the procedure if you want because this code won't give you the desire output but only give you the main idea..cheers.. :)

Code:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Uva_272 {
    public static void main(String args[]) throws IOException{
    Scanner in=new Scanner(System.in);
    InputStreamReader In=new InputStreamReader(System.in);
    BufferedReader br=new BufferedReader(In);
    StringBuilder str=new StringBuilder();
    String tomato="";
    int v=0;
    while((tomato=br.readLine())!=null){
    for(int i=0;i<tomato.length();i++){
    if(tomato.charAt(i)=='\"'){
    v++;
    if(v%2!=0){
    str.append("``");
    }else{
    str.append("\'\'");
    }
    }else{
    str.append(tomato.charAt(i));
    }
    }
    System.out.println(str);
    str.append("\n");
    }
    } 
    }

No comments:

Post a Comment