View Code of Problem 3924

#include<bits/stdc++.h>
using namespace std;
int main() {
	string str;
	while (getline(cin, str))
	{
		char c;
		for (int i = 0; i < str.length(); i++) {
			if (i == 0) {	// 首个字母必然不会重复
				c = str[i];
				cout << c;
				continue;
			}
			if (c == str[i])
				continue; 
			else{
				cout << str[i];
				c = str[i];
			}
		}
		cout << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3924