Run ID:140481

提交时间:2025-12-14 18:26:13

#include <iostream> using namespace std; bool cmp(char a, char b) { if (abs(a-b)==32 || a-b == 0) { return true; } return false; } char upper_case(char a) { if (a>='A' && a<='Z') { return a; } return a-32; } int main(){ string s; cin>>s; if (s.size()==1) { cout<<"("<<upper_case(s[0])<<","<<1<<")"; } char t = s[0]; int cnt = 1; for (int i = 1;i<s.size();i++) { if (cmp(s[i],t)) { cnt++; }else { cout<<"("<<upper_case(t)<<","<<cnt<<")"; cnt=1; t = s[i]; } } cout<<"("<<upper_case(t)<<","<<cnt<<")"; return 0; }