def modify_count(s): upper_count = 0 lower_count = 0 for c in s: if c.isupper(): upper_count += 1 else: lower_count += 1 return min(upper_count, lower_count) s = input("字符串:") print("number", modify_count(s))将这串python代码改成C++语言
时间: 2024-02-29 19:52:34 浏览: 70
将Python转换为C或C ++
以下是修改后的 C++ 代码:
```c++
#include<iostream>
#include<string>
using namespace std;
int modify_count(string s) {
int upper_count = 0;
int lower_count = 0;
for (char c : s) {
if (isupper(c)) {
upper_count++;
} else {
lower_count++;
}
}
return min(upper_count, lower_count);
}
int main() {
string s;
cout << "字符串:";
cin >> s;
cout << "number " << modify_count(s) << endl;
return 0;
}
```
阅读全文