×
解除綁定,重新設定系統帳號的密碼
您的系統帳號 ID:
您的系統帳號:
您的帳號暱稱:
設定新密碼:
設定新密碼:
×
請輸入要加入的「課程代碼」
請向開設課程的使用者索取「課程代碼」
Problems
Submissions
Rank
Forum
Contest
Login
Register
New Thread
#20891: 字串解法
terhead8775
(terhead8775)
School : 國立內壢高級中學
ID : 87826
×
傳送站內訊息
To:
Subject:
Content:
IP address : [36.227.66.229]
Last Login :
2020-10-07 01:16:08
d139.
Compressed String
--
章魚教學網站-97學年度程設馬拉松賽
| From: [220.132.71.132] | Post Date : 2020-03-16 14:32
字串解法
#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
int a =1;
while(cin >>str){
int len = str.length();
for(int i =0;i<len;i++){
if(str[i]==str[i+1]){
a++;
}
else{
if(a==2)
{
cout << str[i] << str[i];
}
elseif(a!=1)
{
cout << a << str[i];
}
else
{
cout << str[i];
}
a=1;
}
}
cout << endl;
}
return0;
}
ZeroJudge Forum