Skip to content
Archive

UVa Online Judge Challenge "272"

“TEX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hopes, a beautiful document. Beautiful documents use…”

UVa Online Judge Challenge "272"

Problem

My Solution

import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        
        boolean verticalMarks = false;
        
        while (sc.hasNextLine()) {

            StringBuilder sb = new StringBuilder();

            String input = sc.nextLine();

            for (int i = 0; i < input.length(); i++) {
                
                if (input.charAt(i) == 34) {

                    if (!verticalMarks) {

                        sb.append("``");

                        verticalMarks = true;

                    } else if (verticalMarks) {
                        
                        sb.append("''");
                        
                        verticalMarks = false;

                    }

                } else {

                    sb.append(input.charAt(i));

                }

            }

            System.out.println(sb);

        }

    }

}

Related Reading

Related entries

Ranked from shared tags, categories, and keywords, with recent section entries used as a fallback.

Relationship Map

Connected Memory

This relationship map centers on the current entry and highlights connected categories and tags.

Categories 0
Tags 0
Entries 0