Skip to content

Commit

Permalink
fix: cpp print code
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jun 26, 2023
1 parent ae2a9b9 commit dce5092
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lang/cpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c cpp) getParamString(params []leetcode.MetaDataParam) string {
func (c cpp) generateScanCode(q *leetcode.QuestionData) string {
if q.MetaData.SystemDesign {
return fmt.Sprintf(
"\t%s %s\n",
"\t%s\n\t%s\n",
c.getDeclCodeForType(1, "string", systemDesignMethodListName),
c.getScanCodeForType(systemDesignMethodListName, inputStreamName),
)
Expand All @@ -120,7 +120,7 @@ func (c cpp) generateScanCode(q *leetcode.QuestionData) string {
for _, param := range q.MetaData.Params {
dimCnt, cppType := c.getCppTypeName(param.Type)
scanCode += fmt.Sprintf(
"\t%s %s\n",
"\t%s\n\t%s\n",
c.getDeclCodeForType(dimCnt, cppType, param.Name),
c.getScanCodeForType(param.Name, inputStreamName),
)
Expand Down Expand Up @@ -238,7 +238,7 @@ func (c cpp) generatePrintCode(q *leetcode.QuestionData) (printCode string) {
if !q.MetaData.SystemDesign {
printCode += "\t" + c.getPrintCodeForType(returnName, outputStreamName) + "\n"
}
printCode += fmt.Sprintf("\tcout << \"\n%s \" << %s.rdbuf() << endl;\n", testCaseOutputMark, outputStreamName)
printCode += fmt.Sprintf("\tcout << \"\\n%s \" << %s.rdbuf() << endl;\n", testCaseOutputMark, outputStreamName)
return
}

Expand All @@ -248,13 +248,7 @@ func (c cpp) generateTestContent(q *leetcode.QuestionData) (string, error) {
stringstream ` + outputStreamName + `;
%s
%s
%s
%s
%s%s%s
delete ` + objectName + `;
return 0;
}`
Expand Down

0 comments on commit dce5092

Please sign in to comment.