题解 | 小红的多彩糖葫芦
小红的多彩糖葫芦
https://www.nowcoder.com/practice/c97aabc25f284994a23c4f21039ffe6d
// #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432 // 模拟题,如果把一个一个的char输入改成string输入,可能可以减少系统API调用次数,提高性能 #include <iostream> using namespace std; int main() { char last, c; int ans = 1; cin >> last; while(cin >> c){ if (c == last){ cout << ans; return 0; } else{ ans++; last = c; } } cout << ans; return 0; } // 64 位输出请用 printf("%lld")#写题解领奖励##牛客春招刷题训练营#