This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner scn = new Scanner(System.in); | |
int count =0; | |
while(scn.hasNext()) { | |
char str[]=scn.nextLine().toCharArray(); | |
for(int i=0;i<str.length;i++) { | |
if(str[i]=='\"') { | |
if(count%2==0) | |
System.out.print("``"); | |
else | |
System.out.print("''"); | |
count++; | |
}else | |
System.out.print(str[i]); | |
} | |
System.out.println(); | |
} | |
} | |
} |
這題別想太複雜把獨到的每列字串轉成字元陣列再一個一個下去找雙引號,記住每行 ` ' 的順序延續上一行,所以我把count放在最外層
範例測資:
Input:
"""
"""
Output:
``''``
''``''