| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 107360 | 刘慕莀 | 行程长度压缩 | C++ | Compile Error | 0 MS | 0 KB | 664 | 2025-01-17 15:31:46 |
#include <iostream> using namespace std; string compress(string str) { string result = ""; char currentChar = toupper(str[0]); int count = 1; for (int i = 1; i < str.length(); ++i) { if (toupper(str[i]) == currentChar) { count++; } else { result += "(" + currentChar + "," + to_string(count) + ")"; currentChar = toupper(str[i]); count = 1; } } result += "(" + currentChar + "," + to_string(count) + ")"; return result; } int main() { string input; cin >> input; cout << compress(input) << endl; return 0; }
Main.cc: In function 'std::__cxx11::string compress(std::__cxx11::string)':
Main.cc:9:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < str.length(); ++i) {
^
Main.cc:13:43: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
result += "(" + currentChar + "," + to_string(count) + ")";
^
Main.cc:19:35: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
result += "(" + currentChar + "," + to_string(count) + ")";
^